Forum Discussion
Time - intelligence: YTD/ LYTD
- 5 years ago
Hi, auxilio99357
Yes, if you use time intelligence functions, such as TOTALYTD, then you need to select a specific date, such as 2020. If the context does not have a specific year,it will select the date with the largest date, so an error occurs.
In a line chart with a year, the time intelligence function should be no problem, but if it used in the table, you need to rewrite the measure and specify a specific year.
Like:
2020YTD = CALCULATE ( SUM ( Sales[Units] ), YEAR ( DimDates[Date] ) = 2020 )If you only put the month on the slicer, it will include all the corresponding months of the year, then there will be loopholes in the logic you said. Please try to understand what I said and make changes.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I understand what you said and I rewrite the measure YTD and it works ok.
But now i don´t know how to change de LYTD measure, because if I do the same with LYTD like this:
2020LYTD =
CALCULATE ( SUM ( Sales[Units] ), YEAR ( DimDates[Date] ) = 2019 )
The measure will sum up the whole 2019 instead of the parcial months. I can filter the months manually but my goal is to write a measure that calculate the results automatically.
Thats why I add the page filter (Year (from DimDates) = 2020) and expect that this measures work:
YTD = TOTALYTD( SUM ( Sales[Units] ), DimDates[Date] )
LYTD = CALCULATE( [YTD] , SAMEPERIODLASTYEAR ( DimDates[Date] ) )
but again LYTD sums up the whole 2019.
Can you think another why to solve it?
Regards!
Auxilio99357
Hi, auxilio99357
You want the data not to change according to the filter, right?
If yes, you can try:
2020LYTD =
CALCULATE ( SUM ( Sales[Units] ), YEAR ( DimDates[Date] ) = 2019 ,filter(all(table)))Best Regards
Janey Guo