Forum Discussion

peteru9067's avatar
peteru9067
Icon for Helper III rankHelper III
5 years ago
Solved

Dax Measures

I am trying to write a dax measures for finding the number of dates between two dates in column A & B....... I do not want to add a calculated column but a dax measures that will perform the differen...
  • Samarth_18's avatar
    5 years ago

    You can try below code.

     

    Date_Diff =
    var calculate_diff = DATEDIFF(MAX('Dates_table'[Column A]),MAX('Dates_table'[Column B]),DAY)
    return IF(calculate_diff < 0,calculate_diff * -1,calculate_diff)
     

     

     
  • Samarth_18's avatar
    Samarth_18
    5 years ago

    You can create measure with below code to achive this

     

    Date_Differences =
    VAR calculate_diff =
    DATEDIFF ( MAX ( 'Test'[Column A] ), TODAY(), DAY )
    RETURN
    IF (
    MAX ( 'Test'[Column A] ) <= TODAY ()
    && MAX ( 'Test'[Column B] ) = DATE ( 1899, 12, 31 ),
    calculate_diff,
    FORMAT ( MAX ( 'Test'[Column B] ), "MM/DD/YYYY" )
    )
     
    PFA screenshot of output