Forum Discussion
JohnYetsko
1 year agoNew Member
DAX - DateDiff not working correctly
I'm using a DAX expression to compare a date column to todays date and enter a comment in a column based on the dfference. However it appears that the DATEDIFF function is not working on dates after...
- 1 year ago
Hello JohnYetsko
DATEDIFF('Plans-DR'[Expires], TODAY(), DAY)
This calculates the number of days from Expires to Today, which means:
If Expires = 07/03/2024 and Today = 04/30/2025, result = ~300 days
But if Expires = 07/04/2024, it's less than 300, so the IF logic flips
But ā your logic might be reversed depending on which way you're counting.
If you're checking how many days left until the expiry date, you should flip the arguments in DATEDIFF:
PlanCompliance =
IF (
ISBLANK('Plans-DR'[Expires]),
"No Plan Dates",
IF (
DATEDIFF(TODAY(), 'Plans-DR'[Expires], DAY) > 300,
"Non-Compliant",
"Compliant"
)
)
If this solved your issue, please mark it as the accepted solution. ā
aduguid
1 year agoMemorable Member
Try this DAX
PlanCompliance =
IF (
ISBLANK ( 'Plans-DR'[Expires] ),
"No Plan Dates",
IF (
'Plans-DR'[Expires] - TODAY() > 300,
"Non-Compliant",
"Compliant"
)
)