Hello all,
I was looking for a way to create a calculated column that auto calculate the duration between dates in a date column called orderdate, with a filter of another column let’s call it Product.
I composed the following expression:
ByAymanProductFlowDays =
var currentproduct=Sales[ProductName]
var previousdate=MAXX(FILTER(Sales,Sales[ProductName]=currentproduct&&Sales[OrderDate]<EARLIER(Sales[OrderDate])),Sales[OrderDate])
var result=IF(ISBLANK(previousdate),0,Sales[OrderDate]-previousdate)
return result
When using this expression on adventureworks data I got the results as shown in the following image
In the small red circle there are two consecutive values of 1. My goal is to subtract the dates in the red column
so because the relevant dates are identical the yellow highlited value should be zero.
How to fix the DAX expression or rewrite it to meet my goals?
Than you all
Ayman