Forum Discussion

jobf's avatar
jobf
Helper II
2 years ago
Solved

Difference between several dates in the same column

Hello. I need to calculate the difference between several dates in the same column. For example: Field  Date P1 01/01/2024 P1 01/03/2024 P1 01/06/2024 P1 01/11/2024 P2 02/02/...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi jobf 

     

    Thanks for the reply from samratpbi .

     

    jobf , you can try the following measure:

    Difference = 
    VAR _Previous = MAX('Table'[Date])
    VAR _PreviousRowDate = 
        CALCULATE(
            MAX('Table'[Date]),
            FILTER(
                ALLEXCEPT('Table', 'Table'[Field]),
                'Table'[Date] < _Previous
            )
        )
    RETURN
        IF(
            ISBLANK(_PreviousRowDate),
            0,
            MAX([Date]) - _PreviousRowDate
        )

     

    Output:

     

    Best Regards,
    Yulia Xu

     

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