Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate time difference based on Rank & Date time

Hi Guys,   I have a unique request to calculate the time difference between 2 orders -   Below is the sample data for your reference   Order  no Person name datetime Rank Time difference...
  • V-lianl-msft's avatar
    V-lianl-msft
    6 years ago

    Hi Anonymous ,

     

    Use the "EARLIER" function :

     

    Difference3 =
    VAR currentindex_ = Sheet2[Index]
    VAR t_date =
        CALCULATE (
            MAX ( Sheet2[datetime] ),
            FILTER (
                Sheet2,
                Sheet2[Index] = currentindex_ - 1
                    && Sheet2[Rank] = 3
                    && Sheet2[Person name]
                        = EARLIER ( Sheet2[Person name] )
            )
        )
    RETURN
        DATEDIFF (
            t_date,
            Sheet2[datetime],
            SECOND
        )

     

     Also you can refer to this .pbix

     

    Best Regards,

    Liang 

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