Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JohnYetsko
New 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 July 3rd 2024.

I can update the field to 7/3/2024 and it functions correctly, but entering 7/4/2024 it does not.

 

******

PlanCompliance =

IF(

ISBLANK('Plans-DR'[Expires]),

"No Plan Dates",

IF(

DATEDIFF('Plans-DR'[Expires], TODAY(), DAY) > 300,

"Non-Compliant",

"Compliant"

)

)

1 ACCEPTED SOLUTION
Amar_Kumar
Resolver I
Resolver I

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.

View solution in original post

6 REPLIES 6
v-priyankata
Community Support
Community Support

Hi @JohnYetsko 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

v-priyankata
Community Support
Community Support

Hi @JohnYetsko 
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-priyankata
Community Support
Community Support

Hi @JohnYetsko 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

aduguid
Super User
Super User

Try this DAX

PlanCompliance =
IF (
    ISBLANK ( 'Plans-DR'[Expires] ),
    "No Plan Dates",
    IF (
        'Plans-DR'[Expires] - TODAY() > 300,
        "Non-Compliant",
        "Compliant"
    )
)
Amar_Kumar
Resolver I
Resolver I

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.

lbendlin
Super User
Super User

Are you trying to do this as a measure?  It works correctly as a calculated column

 

lbendlin_0-1746111126572.png

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.