Forum Discussion

Ecan20's avatar
Ecan20
Frequent Visitor
5 years ago
Solved

DAX to compute the difference between date for specific items

Dear experts, I have a table like the example below with product ID, StartDate, EndDate. I would like to calculate the difference between the last EndDate and the first StartDate per each iem ID, li...
  • mahoneypat's avatar
    5 years ago

    Please try this column expression and convert the column to type decimal.

     

    NewColumn =
    VAR thisID = IDs[ID]
    VAR minDT =
        MINX ( FILTER ( IDs, IDs[ID] = thisID ), IDs[StartDate] )
    VAR maxDT =
        MAXX ( FILTER ( IDs, IDs[ID] = thisID ), IDs[EndDate] )
    RETURN
        maxDT - minDT

     

    Pat