Forum Discussion
Unknown
4 years agoFrequent Visitor
Difference between two rows
Hello, I have a table that looks like this (Please note that my date is in the format DD/MM/YYYY): I want to calculate the difference between two following dates where condition=1. I man...
- 4 years ago
Hi Unknown
You can usedatediff = VAR CurrentDate = 'Table'[date] VAR PreviousTable = FILTER ( 'Table', 'Table'[date] < CurrentDate && 'Table'[condition] <> BLANK () ) VAR PreviousDate = MAXX ( PreviousTable, 'Table'[date] ) RETURN IF ( 'Table'[condition] = 1 && NOT ISEMPTY ( PreviousTable ), DATEDIFF ( PreviousDate, CurrentDate, DAY ) )
tamerj1
4 years agoCommunity Champion
Hi Unknown
You can use
datediff =
VAR CurrentDate = 'Table'[date]
VAR PreviousTable =
FILTER (
'Table',
'Table'[date] < CurrentDate
&& 'Table'[condition] <> BLANK ()
)
VAR PreviousDate =
MAXX ( PreviousTable, 'Table'[date] )
RETURN
IF (
'Table'[condition] = 1
&& NOT ISEMPTY ( PreviousTable ),
DATEDIFF ( PreviousDate, CurrentDate, DAY )
)