Forum Discussion
Calculating the Date/Time difference between two rows (not always consecutive)
- 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.
- 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?
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.
- DarrelDonatto4 years agoFrequent Visitor
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?