Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi,
I want to calculate the number of days between today and the last time a customer made a purchase order. I have a table with the purchase order nr as key and then the customer nr and purchase date. For every customer I want to know how long it has been since his last puchase. I tried to make a measure with the datedifference function but it never gives the correct result. Does anybody knows how to do this? 🙂
Thanks in advance!
Solved! Go to Solution.
Calculate Max Order Date Per Customer using ALLEXCEPT and then calculate Datediff with today.
Time Since Last Order Date =
Var LastOrderDt = CALCULATE(MAX('P6:TimeSinceLastOrder'[OrderDate]), ALLEXCEPT('P6:TimeSinceLastOrder','P6:TimeSinceLastOrder'[CustomerId]))
Var TimeSinceLastOrderDt = DATEDIFF(LastOrderDt,TODAY(),DAY)
RETURN TimeSinceLastOrderDt
Calculate Max Order Date Per Customer using ALLEXCEPT and then calculate Datediff with today.
Time Since Last Order Date =
Var LastOrderDt = CALCULATE(MAX('P6:TimeSinceLastOrder'[OrderDate]), ALLEXCEPT('P6:TimeSinceLastOrder','P6:TimeSinceLastOrder'[CustomerId]))
Var TimeSinceLastOrderDt = DATEDIFF(LastOrderDt,TODAY(),DAY)
RETURN TimeSinceLastOrderDt
Create this measure:
Days Since Last Order = DATEDIFF(MAX(Sales[OrderDate]), TODAY(), DAY)
Then use it in a table with the customer key or name
This does not seems to work if I try to adjust the current date
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 56 | |
| 52 | |
| 45 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 108 | |
| 108 | |
| 39 | |
| 33 | |
| 25 |