Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Difference calculation between two date fields.

  I am trying to calculate the datediff between Date1 and Date2 fields.  Please note that Date2 column has values that are -1  If the date2 <0 , substitute the date2 value to today() before calcula...
  • amitchandak's avatar
    3 years ago

    Anonymous , I Power Query Replace them with Date.From(DateTime.FixedLocalNow()))

     

    First replace -1 with null

     

    then change datatype to date and then create a new column

     

    if [Date2] = null then Date.From(DateTime.FixedLocalNow())) else [Date2]

     

     

    Then you can use datediff in DAX

     

    DAX

     

    Datediff([Date1], [Date2], day)

     

    or

     

     

    Datediff([Date2], [Date1], day)