Forum Discussion
DAX for date difference
- 5 years ago
Hi Anonymous ,
so here is a third variation:
Difference in Month = VAR _StartLessThanEnd = IF ( OR ( 'Table'[Start], 'Table'[End] ) = BLANK (), BLANK (), DATEDIFF ( 'Table'[Start], 'Table'[End], MONTH ) + 1 ) VAR _EndLessThanStart = IF ( OR ( 'Table'[Start], 'Table'[End] ) = BLANK (), BLANK (), DATEDIFF ( 'Table'[End], 'Table'[Start], MONTH ) + 1 ) RETURN if ( 'Table'[Start] < 'Table'[End], _StartlessThanEnd, _EndLessThanStart)With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Hi Anonymous
if the absolute number in 'Test Term' is correct and you want only to get reed of the negativ sign then use the following measure:
Difference in Month =
IF (
OR ( 'Table'[Start], 'Table'[End] ) = BLANK (),
BLANK (),
ABS( DATEDIFF ( 'Table'[Start], 'Table'[End], MONTH ) + 1 )
)
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
- Anonymous5 years agoNot applicable
Hi FrankAT ,
Thak you for the prompt reply but the value is also wrong for these dates
start date =01-19-2022 -end date =03-31-2021 = 11 months but its giving -9
- FrankAT5 years agoCommunity Champion
Hi Anonymous ,
so here is a third variation:
Difference in Month = VAR _StartLessThanEnd = IF ( OR ( 'Table'[Start], 'Table'[End] ) = BLANK (), BLANK (), DATEDIFF ( 'Table'[Start], 'Table'[End], MONTH ) + 1 ) VAR _EndLessThanStart = IF ( OR ( 'Table'[Start], 'Table'[End] ) = BLANK (), BLANK (), DATEDIFF ( 'Table'[End], 'Table'[Start], MONTH ) + 1 ) RETURN if ( 'Table'[Start] < 'Table'[End], _StartlessThanEnd, _EndLessThanStart)With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)