Forum Discussion
shivanirawat
3 years agoFrequent Visitor
How to get the Date Difference from a date column, if Part number of 2 row is equal to previous row.
I need a Dax expression, where I need to find out the date difference, if part number of 2nd row = Previous(Part number of 1st row). Suppose this is the table, where I need Dax formula,...
- 3 years ago
Days Diff = VAR CurrentPartNumber = 'Raw Data'[Part_Number] VAR CurrentPartDate = 'Raw Data'[Date] VAR SamePartRows = FILTER ( 'Raw Data', 'Raw Data'[Part_Number] = CurrentPartNumber && 'Raw Data'[Date] > CurrentPartDate ) VAR ImmediateNextDate = MINX ( SamePartRows, 'Raw Data'[Date] ) VAR Difference = INT ( ImmediateNextDate - CurrentPartDate ) VAR Result = IF ( COUNTROWS ( SamePartRows ) > 0, Difference, 0 ) RETURN Result
AntrikshSharma
Community Champion
3 years agoDays Diff =
VAR CurrentPartNumber = 'Raw Data'[Part_Number]
VAR CurrentPartDate = 'Raw Data'[Date]
VAR SamePartRows =
FILTER (
'Raw Data',
'Raw Data'[Part_Number] = CurrentPartNumber
&& 'Raw Data'[Date] > CurrentPartDate
)
VAR ImmediateNextDate =
MINX ( SamePartRows, 'Raw Data'[Date] )
VAR Difference =
INT ( ImmediateNextDate - CurrentPartDate )
VAR Result =
IF ( COUNTROWS ( SamePartRows ) > 0, Difference, 0 )
RETURN Result