Forum Discussion
jereaallikko
Helper III
4 years agoHow to Calculate Time difference from MIN Timestamp and MAX Timestamp in same Column
Hi all, I am trying to calculate a time difference (ideally on hh/mm/ss format) from different rows from earliest timestamp and latest timestamp. My data contains ID and Timestamp (date/time)...
- 4 years ago
Hi jer:
You could do a few measures.
MIN Time value = CALCULATE(MIN(Data[Time]), ALLEXCEPT(Data,Data[ID]))MAx Time value = CALCULATE(MAX(Data[Time]), ALLEXCEPT(Data,Data[ID]))Time Difference H = DIVIDE( DATEDIFF([MIN Time value],[MAX Time value],MINUTE),60)Here's the result using some of my data:(Please note format is LongTime)My Data table named Data
- Anonymous4 years ago
Hi jereaallikko ,
Please check this measure.
Measure = VAR min_ = CALCULATE(MIN('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID])) VAR max_ = CALCULATE(MAX('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID])) var vSeconds=DATEDIFF(min_,max_,SECOND) var vMinutes=int( vSeconds/60) var vRemainingSeconds=MOD(vSeconds, 60) var vHours=INT(vMinutes/60) var vRemainingMinutes=MOD(vMinutes,60) var vDays=INT(vHours/24) var vRemainingHours=MOD(vHours,24) return vDays&" "& vRemainingHours&":"& vRemainingMinutes&":"& vRemainingSecondsBest Regards,
Jay
Whitewater100
Solution Sage
4 years agoHi jer:
You could do a few measures.
MIN Time value = CALCULATE(MIN(Data[Time]), ALLEXCEPT(Data,Data[ID]))
MAx Time value = CALCULATE(MAX(Data[Time]), ALLEXCEPT(Data,Data[ID]))
Time Difference H = DIVIDE( DATEDIFF([MIN Time value],[MAX Time value],MINUTE),60)
Here's the result using some of my data:(Please note format is LongTime)
My Data table named Data