Forum Discussion

Ben1981's avatar
Ben1981
Helper III
2 years ago
Solved

Measure to replace null date with specific date

Hi, someone please help before I pull my hair out! I am trying to write a DAX measure that essentially replaces a null date value with another date value.  I created a table visual that has 3 colu...
  • Ahmedx's avatar
    2 years ago

    pls try this

    if ( ISBLANK(yourtable[End_date]),TODAY()-1,yourtable[End_date])
    -----------or---------------------
    if ( ISBLANK(MAX(yourtable[End_date])),TODAY()-1,MAX(yourtable[End_date]))

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Ben1981 

     

    Maybe you can try this:

    First of all, I created a sample:

    Transform Data > (Right-Click the null) Replace Values.

    Insert null(or other values that don't affect the report)

     

    Change the second null into

     

    Date.AddDays(DateTime.LocalNow(),-1)
    //Use M Query to return the date/time yesterday.

     

    Like this:

    Then change the column type to Date.

    The result is as follow:

    Documentation on M Query:

    Power Query M function reference - PowerQuery M | Microsoft Learn

    Time Queries:

    DateTime functions - PowerQuery M | Microsoft Learn

     

    Best Regards,

    Zhengdong Xu

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