Forum Discussion
kav_cris
3 years agoFrequent Visitor
Date difference between 2 previous months
Hi all, I am trying to calculate the storage time (in days) for unsold items, historically. Let's say I bought product A in Jan 2022 and it is still stored today. DATEDIFF(Sales[PurchaseDate...
kav_cris
3 years agoFrequent Visitor
Some more info, my measure looks like this:
Datediff =
CALCULATE(
if(
SELECTEDVALUE('Date'[MonthEndDate]) >= SELECTEDVALUE(Sales[PurchasedDate]) ,
DATEDIFF(SELECTEDVALUE(Sales[PurchasedDate]), SELECTEDVALUE('Date'[MonthEndDate]) , DAY),
"f"
), USERELATIONSHIP(Sales[PurchasedDate], 'Date'[Date]))
And I get this result:
It only calculates the datediff to the month itself.
I want the difference to all following month ends.