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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
richrich123
Helper III
Helper III

Where have I gone wrong with datediff measure?

Morning,

 

Just looking to apply conditional formatting to cases that are overdue updates. In this example, the last update is far greater than 2 days but is still showing 0. Have I got something wrong in the measure or is if for some reason not recognising the date? 

richrich123_0-1671530908412.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @richrich123 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1671587557801.png

(2) We can create a measure.

Older than 2 days = 
IF(DATEDIFF(SELECTEDVALUE('Case'[lastcustomerupdate]),TODAY(),DAY)>2,1,0)

(3) Then the result is as follows.

vtangjiemsft_1-1671587663320.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

16 REPLIES 16
richrich123
Helper III
Helper III

@Idrissshatila , hi and thanks for the suggestion. I have tried swapping today() to before my selected date but it then is only offering me to compare to measures in the case data and not my selected date? All those in the drop down are measures only and don't contain any fields e.g my lastupdated filed.

 

richrich123_0-1671533658115.png

 

Hello,

can you paste the first measure here



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




@Idrissshatila 

 

Older than 2 days = IF( DATEDIFF(SELECTEDVALUE('Case'[lastcustomerupdate].[Date]),TODAY(), DAY) > 2,1,0)

Try it like this

Older than 2 days = IF( DATEDIFF(TODAY(), SELECTEDVALUE('Case'[lastcustomerupdate].[Date]),DAY) > 2,1,0)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Thanks, it accepted that measure but its still returning 0 for every item including those over 2 days?

 

richrich123_0-1671536493332.png

 

try it now :

Older than 2 days = IF( DATEDIFF(SELECTEDVALUE('Case'[lastcustomerupdate].[Date]),TODAY(), DAY) < -2,1,0)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




@Idrissshatila , frustratingly still returning a 0 for the example that is weeks old 

richrich123_0-1671547996006.png

 

Weird, you're sure its the right date field that's referenced in the dax measure?



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




@Idrissshatila Have double checked and also removed and re-added fields. You can see the date field and the dax measure both tie up and are the same measure and date field in the measure as is applied to the table fields? Have double checked and all looks spot on 

richrich123_0-1671549532312.png

Checked it is 100% formatted as a date field as well and all fine

richrich123_2-1671550013595.png

 

Try this:

 

Older than 2 days = IF( DATEDIFF('Case'[lastcustomerupdate],TODAY(), DAY) >2,1,0)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




richrich123_0-1671550711959.png

 

then lets try it like this

Older than 2 days = IF( DATEDIFF(SELECTEDVALUE('Case'[lastcustomerupdate].[Date]),TODAY(), DAY) >2,1,0)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




The measure works but again, output for a date far greater than 2 days old is still zero. 

richrich123_0-1671553419986.png

 

Anonymous
Not applicable

Hi @richrich123 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1671587557801.png

(2) We can create a measure.

Older than 2 days = 
IF(DATEDIFF(SELECTEDVALUE('Case'[lastcustomerupdate]),TODAY(),DAY)>2,1,0)

(3) Then the result is as follows.

vtangjiemsft_1-1671587663320.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

@Anonymous  - amazing - that has worked, thanks very much for your assitance, much appreciated.

Idrissshatila
Super User
Super User

Hello,

 

Try switching the two dates, put the today(), then the your selected date.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos!

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors