dax

How to find the DATEDIFF() in DAX


I have a data table as below and if today is 5\25\2025, the expected answer should be 3 days.

DateColumn   
5\24\2025   
null
5\22\2025  

Measure = TODAY() - MIN(NOT(ISBLANK(DateColumn))) 
Expected Answer =  5\25\2025 - 5\22\2025  

when I try

Measure = TODAY() - CALCULATE( MIN('table'[column]), NOT ISBLANK('table'[column]) )

I am getting wrong dates since the latest data is in my df goes back to 2022. enter image description here


Solution

  • You'll need to use the CALCULATE function to get the conditional MIN.

    Measure = TODAY() - CALCULATE( MIN('table'[column]), NOT ISBLANK('table'[column]) )
    

    Looks like you don't have null for your dates. Either update those to null in Power Query or update the measure to:

    Measure = TODAY() - CALCULATE( MIN('table'[column]), YEAR('table'[column]) > 2000 )