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
adjust your formula like this:
= 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)
Hi FrankAT,
I cannot use +1 at the end blanks in start and end dtae columns and they would appear as 1 in my new column.
- FrankAT5 years agoCommunity Champion
Hi Anonymous ,
use the following solution:
Difference in Month = IF ( OR ( 'Table'[Start], 'Table'[End] ) = BLANK (), BLANK (), 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 ,
This is working but there is an issue with dates whose end date(day) is greater than start date(day) its givning negative values as highlighted below