Forum Discussion
Modelling Time Calculation with irregular intervals
JulianaMacedo Not clear what your expected output should be. 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
- JulianaMacedo4 years ago
Helper II
Ok Hi!
Thanks for answering, I think it was also a bit unclear to me what should I do, but I got this information now:
I need basically to calculate the total time between the beggining of the interval and the end of the interval per hour. For every hour, take the first timestamp and then the last and calculate how many minutes/seconds.
I'll take a look at the article and see if that helps, thanks for the collaboration.- Greg_Deckler4 years ago
Community Champion
JulianaMacedo Right, you can use MINX and MAXX to get the minimum and maximum timestamps by using a FILTER for HOUR. So,
MinTS =
VAR __Hour = HOUR([timestamp])
RETURN
__Min = MINX(FILTER('Table',HOUR([timestamp] = __Hour)
- JulianaMacedo4 years ago
Helper II
I think it might be something in that direction, but it's not helping actually....maybe if I try to clarify better:
I'm trying to working on a measure that will do the following:
Measure =
Calcuate(
difference between the lastest timestamp and the earliest time stamp),
filter (by hour))
I was trying to mix your answer with the following code, i tried different sintax that did not work:MaxHour = CALCULATE ( MAX ( 'Table'[Column to calculate] ), FILTER ( 'Table', 'Table'[Date] = EARLIER ( 'Table'[Date] ) && HOUR ( 'Table'[Time] ) = HOUR ( EARLIER ( 'Table'[Time] ) ) ) )