Forum Discussion
Anonymous
2 years agoNot applicable
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 Date | Request Date | Date Diff |
| 1/1/2024 | 1/9/2024 | 8 |
| 1/5/2024 | 1/10/2024 | 5 |
| 1/10/2024 | 1/11/2024 | 1 |
| 1/21/2024 | 1/12/2024 | 0 |
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
- vicky_
Super User
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)