Forum Discussion

1Kash_PBI's avatar
1Kash_PBI
Frequent Visitor
5 years ago
Solved

Calculation Group Variables — MAXX Calendar Date Less Specific Number of Days

Hello All,

 

Within a calculation group, I'm attempting to set up two PriorDay variables that work with selectedmeasure()... The first would be the maxx calendar date less 1 day, and the other maxx calendar date less 364 days.

 

The below DAX for 1 day returns the expected result, but when swapping 1 for 364 I do not. — I've tried different combinations of DATEADD and MIN MAX but no luck

 

I'm sure it's user error. Hoping someone here can help. Thanks!

 

VAR vToday = MAXX('Calendar','Calendar'[Date])

VAR vPriorDay = MAXX('Calendar','Calendar'[Date]) - 1

VAR MeasureToday = CALCULATE(Selectedmeasure(),FILTER('Calendar','Calendar'[Date] = vToday))

VAR MeasurePriorDay = CALCULATE(Selectedmeasure(),FILTER('Calendar','Calendar'[Date] = vPriorDay))

RETURN
MeasureToday - MeasurePriorDay