Forum Discussion
Calculate elapsed time in aggregation
- Anonymous3 years ago
Hi AndyKing ,
Here are the steps you can follow:
1. In Power query. Add Column – Index Column – From 1.
2. Create calculated column.
IF = var _1= VALUE(RIGHT('Table'[SubProcess],1)) return IF(_1=1,1,0)Group = SUMX(FILTER(ALL('Table'),'Table'[Index]<=EARLIER('Table'[Index])),[IF])3. Create measure.
StartTime_Measure = MINX(FILTER(ALL('Table'), 'Table'[Process]=MAX('Table'[Process])&&YEAR('Table'[StartTime])=YEAR(MAX('Table'[StartTime])) &&MONTH('Table'[StartTime])=MONTH(MAX('Table'[StartTime]))&&DAY('Table'[StartTime])=DAY(MAX('Table'[StartTime]))),[StartTime])EndTime_Measure = MAXX(FILTER(ALL('Table'), 'Table'[Process]=MAX('Table'[Process])&&YEAR('Table'[EndTIme])=YEAR(MAX('Table'[EndTIme])) &&MONTH('Table'[EndTIme])=MONTH(MAX('Table'[EndTIme]))&&DAY('Table'[EndTIme])=DAY(MAX('Table'[EndTIme]))),[EndTIme])ElapsedTime (min) = DATEDIFF( [StartTime_Measure],[EndTime_Measure],MINUTE)4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Greg_Deckler,
Thank you very much for the prompt response.
Shouldn't there be a loop to calculate the elapsed time for each process?
In the example above, MIN (StartTime) and MAX(EndTime) should be calculated within each process for each day, so we need to get 4 different elapsed times, two for each day because there are two processes.
Hope that helps.
- Greg_Deckler3 years ago
Community Champion
AndyKing Well, you would need something to differentiate the rows in your table visual. You could add a Day column to your table as a calculated column for example. Something like: DATE(YEAR([StartTime],MONTH([StartTime],DAY([StartTime])) and add that to your visual but don't summarize.