Forum Discussion
ToddMate
3 years agoHelper II
Calculate Time Difference.
Hi, I need assistance determining the time difference in the example below. Using the same tx_number, and then sorting by tx_date, i am trying to determine the response time from "Customer Emai...
- Anonymous3 years ago
Hi ToddMate ,
It's eaiser to achieve by creating a calculated column.
time = VAR _MAX = MAXX ( FILTER ( 'tx_dates', [tx_number] = EARLIER ( tx_dates[tx_number] ) ), [tx_date] ) VAR _SECOND = DATEDIFF ( [tx_date], _MAX, SECOND ) RETURN IF ( [action] = "Customer Email", FORMAT ( ROUNDDOWN ( DIVIDE ( _SECOND, 3600 ), 0 ), "00" ) & ":" & FORMAT ( ROUNDDOWN ( DIVIDE ( MOD ( _SECOND, 3600 ), 60 ), 0 ), "00" ) & ":" & FORMAT ( MOD ( _SECOND, 60 ), "00" ) )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
3 years agoCommunity Champion
ToddMate See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous