Forum Discussion
SAMEPERIODLASTYEAR not working for year
- Anonymous1 year ago
Hi o59393 ,
For the situation you described, you can use the following DAX.Previous Date OU Demand = VAR _Date = CALCULATE(SUM('Append OU Demand'[OU Demand]), SAMEPERIODLASTYEAR('Append OU Demand'[Date])) VAR _Year = CALCULATE(SUM('Append OU Demand'[OU Demand]), DATEADD('Append OU Demand'[Date].[Date],-1,YEAR)) RETURN IF(SELECTEDVALUE('Append OU Demand'[Date]) = BLANK(), _Year,_Date )
Please see the attached pbix for reference.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
As a best practice, add a date dimension in your model and use it for time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools. Check the related videos on my YT channel
Add Date Dimension
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
Also check out this video my YT channel: Explore SAMEPERIODLASTYEAR & PARALLELPERIOD Time Intelligence functions? Are they same? - Part 5 (youtube.com)