Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

How to get yesterday's value using a measure

I have two tables calendar and day after delivery. For each calendar date I am trying to get yesterday's value. If the difference between dates is 1 then it should raise flag to 1 otherwise 0. I will be using this flag as a filter to list all the customer ids on yesterday's date. 

This is my dax :

PreviousDeliveryDate =
VAR ChosenDate = MAX('Calendar'[Date])
VAR PreviousDate = SELECTEDVALUE('Day after delivery'[ActualDeliveryDate]) - 1
VAR ConditionMet = IF(DATEDIFF(ChosenDate, PreviousDate, DAY) = -1, 1,0 )
RETURN
PreviousDate

 

In external filter I have chosen date 2 Nov 2023. This is what it is showing. It is giving wrong dates. Shouldn't it give yesterday's date for each actual delivery date?

 

2 Replies