Forum Discussion
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
- Ritaf1983
Super User
Hi Anonymous
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - v-zhangti
Community Support
Hi, Anonymous
Can you provide more sample data for testing? Sensitive information can be removed in advance.
I tested failed to restore your problem.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.