Forum Discussion

DarrelDonatto's avatar
DarrelDonatto
Frequent Visitor
4 years ago
Solved

Calculating the Date/Time difference between two rows (not always consecutive)

I have a table where date/time values are stored within rows by Incident # and Unit.   I am trying to calculate the difference between these values in any given row for an incident number and unit....
  • v-chenwuz-msft's avatar
    4 years ago

    Hi DarrelDonatto ,

     

    Is this you want?

    You can use matrix table visual to do this with a measure like the following:

    Turnout Time =
    VAR _dis =
        CALCULATE (
            MAX ( 'DateTable'[timestamp] ),
            FILTER ( 'DateTable', [descript] = "dispatched" )
        )
    VAR _enr =
        CALCULATE (
            MAX ( 'DateTable'[timestamp] ),
            FILTER ( 'DateTable', [descript] = "en-route" )
        )
    RETURN
        IF (
            HASONEVALUE ( DateTable[descript] ),
            FORMAT ( MAX ( 'DateTable'[timestamp] ), "mm/dd/yyyy hh:nn:ss AMPM" ),
            FORMAT ( _dis - _enr, "h:mm:ss" )
        )
    

     

     

    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

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

  • DarrelDonatto's avatar
    DarrelDonatto
    4 years ago

    This is great.  Thanks so much.  It solves much of what I am trying to accomplish.  Is there a way to get the same measure not in matrix visualization, but so I can use the result to calculate a 90th percentile or an average per unit?