Forum Discussion
o59393
Post Prodigy
1 year agoSAMEPERIODLASTYEAR not working for year
Hi all I need a dax measure to calculate the previous period values, this could be by year, quarter or month. The dax I have works well only for month and not for year or Q: If I...
- 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.
Anonymous
1 year agoNot applicable
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.