Forum Discussion

JohnYetsko's avatar
JohnYetsko
New Member
1 year ago
Solved

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...
  • Amar_Kumar's avatar
    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. āœ