Forum Discussion

Mafesa_Sasol's avatar
Mafesa_Sasol
Frequent Visitor
3 years ago
Solved

Finding the difference between two dates in different rows

Hi, I would really appreciate any assistance. I am trying to find the difference between the Start and End Date but in different rows and different columns. For example, in the attached data table, I...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi mafesa sasol,

     

    Please find the code :

    Standby Date =
    VAR enddate = Standby[End Date]
    VAR startdate = Standby[Start Date]
    VAR minstartdate =
        CALCULATE (
            MIN ( Standby[Start Date] ),
            FILTER ( ALL ( Standby ), Standby[Start Date] > startdate )
        )
    VAR result =
        DATEDIFF ( enddate, minstartdate, DAY )
    RETURN
        result