Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

calculate Date Diff for positive values only

Is it possible calculate the difference in days between two dates only when the difference is positive? In instances where the difference is negative it should return a 0 . Below would be the expected output.

Create DateRequest DateDate Diff
1/1/20241/9/20248
1/5/20241/10/20245
1/10/20241/11/20241
1/21/20241/12/20240
  • I used the following dax to create a calculated column with your desired results:

    Date Diff = 
    var diff = DATEDIFF('Table'[Create Date], 'Table'[Request Date], DAY)
    return IF(diff < 0 , 0, diff)

     

1 Reply

  • I used the following dax to create a calculated column with your desired results:

    Date Diff = 
    var diff = DATEDIFF('Table'[Create Date], 'Table'[Request Date], DAY)
    return IF(diff < 0 , 0, diff)