Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Tengo una variedad de medidas que aprovechan las expresiones DATESYTD, DATESQTD y DATESMTD, pero encuentro que los intervalos de fechas son ligeramente inconsistentes al comparar con el año anterior.
Ejemplo 1:
Ejemplo 2:
Solved! Go to Solution.
Hey @FrazerPwC ,
Recomiendo leer este artículo, prestar atención a las notas: https://dax.guide/sameperiodlastyear/
Para este reaseon tuve que cambiar la instrucción DAX de dateTable a esto:
DateTable = CALENDAR(
//MIN(Orders[Date]),MAX(Orders[Date])
DATE( 2015 , 1 , 1 )
, DATE( 2020 , 12 , 31 )
)
Luego creé estas dos medidas:
Tom Current Year 2020-01-01 - 09-10 =
var _lastdate = DATE( 2020 , 9 , 10 )
var _firstDayOfTheYear = DATE( YEAR(_lastdate) , 1 , 1 )
var theDates = DATESBETWEEN( 'DateTable'[Date] , _firstDayOfTheYear , _lastdate )
return
CALCULATE(
SUM('Orders'[Sales])
, FILTER(
ALL('DateTable')
, 'DateTable'[Date] in theDates
)
)
Y el más interesante:
Tom Previous Year 2019-01-01 - 09-10 =
var _lastdate = DATE( 2020 , 9 , 10 )
var _firstDayOfTheYear = DATE( YEAR(_lastdate) , 1 , 1 )
var theDates =
SAMEPERIODLASTYEAR(DATESBETWEEN( 'DateTable'[Date] , _firstDayOfTheYear , _lastdate ))
var theStartDate = MINX( theDates , 'DateTable'[Date] )
var theEndDate = MAXX( theDates , 'DateTable'[Date])
var noofday = COUNTROWS( theDates )
var thevalue =
CALCULATE(
SUM('Orders'[Sales])
, FILTER(
ALL('DateTable')
, 'DateTable'[Date] in theDates
)
)
return
"startdate: " & theStartDate
& UNICHAR(10) & "enddate: " & theEndDate
& UNICHAR(10) & "no of days: " & noofday
& UNICHAR(10) & "value: " & thevalue
Es simplemente más redactatorio, ya que también uso esto para documentar lo que está pasando.
Sin embargo, todo esto me permite crear esto:
Con suerte, esto es lo que estás buscando.
saludos
Tom
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |