Process times

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,896
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
  8. 2003 or older
Platform
  1. Windows
I have a large data set and in simplified form here is a snapshot of the data, Column A Process Stage can be either 0 or 1, column B is a process step ID, column C is a time stamp and column D is a process ID,
I can use the process ID to group the data by for my other calculations on the data, what I would like to do now is as follows

1) for each Process ID calculate the duration from start to finish, Process Stage=0, Process Step ID=1 --> Process Stage=1, Process Step Id=10 effectively total job time
2) same as above starting at Process Stage =1, Process Step ID=1 -->Process Stage=1, Process Step Id=10, effectively Total stage 1 time
3) time in seconds between each stage

so below for for 48955002, total duration is 6m 19s, step 1 duration 5m 21s, time between each step at stage=1 , 32s, 26s, 21s, 28s etc for all 10 steps

Book1
ABCD
1StageIDStepIDTimerProcessID
20116:59:0648955002
30216:59:3848955002
41117:00:0448955002
51217:00:2548955002
61317:00:5348955002
71417:02:0548955002
81517:02:3148955002
91617:03:1448955002
101717:03:5948955002
111817:04:4248955002
121917:05:0248955002
1311017:05:2548955002
140115:57:0348555804
150215:57:3448555804
160315:58:3848555804
170415:59:0548555804
180515:59:3448555804
191116:00:1948555804
201216:00:3548555804
211316:01:1648555804
221416:01:5848555804
231516:04:5448555804
241616:05:2748555804
251716:06:0548555804
261816:06:4148555804
271916:07:1348555804
2811016:07:4548555804
290117:15:4048a18404
300217:16:1448a18404
310317:16:4848a18404
320417:17:2948a18404
331117:18:2248a18404
341217:18:5848a18404
351317:19:3448a18404
361417:20:1448a18404
371517:20:5848a18404
381617:21:3448a18404
391717:22:0748a18404
401817:22:4348a18404
411917:23:1948a18404
4211017:23:5748a18404
430117:13:5648a1a806
440217:14:2948a1a806
450317:15:1348a1a806
461117:15:4848a1a806
471217:16:1848a1a806
481317:16:4548a1a806
491417:17:3048a1a806
501517:18:0748a1a806
511617:18:3548a1a806
521717:19:0948a1a806
531817:19:3748a1a806
541917:20:0948a1a806
5511017:20:3348a1a806
560117:48:3448b8a006
570217:49:1048b8a006
580317:49:5148b8a006
590417:50:1548b8a006
600517:50:5148b8a006
611117:51:3548b8a006
621217:52:0848b8a006
631317:52:4048b8a006
641417:53:1248b8a006
651517:53:4348b8a006
661617:54:1248b8a006
671717:54:3648b8a006
681817:55:1948b8a006
691917:55:4748b8a006
7011017:56:1448b8a006
Sheet1
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
time between each step at stage=1 , 32s, 26s, 21s, 28s etc for all 10 steps

You only want this for stage 1? Because the data you are talking about there belongs to stage 0 too.

32s, 26s are in stage 0
 
Upvote 0
Ooops in my haste I included 32s, 26s
I have been looking at using an index column to bring in the previous row into a calculation of (currentrow - previous row) but getting myself in a mess
 
Upvote 0
Here is my version. Everything in one Table.Group. I hope it is as expected.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    result = Table.Group(Source, {"ProcessID"},
        {
      
            {"TotalDur", each List.Max([Timer]) - List.Min([Timer])},
            {"Duration1_10", each

                        let
                            tbl = Table.Buffer(_) ,
                            tbl2 = Table.Sort(Table.SelectRows(tbl , each [StepID] = 1 or [StepID] = 10 ),{{"Timer", Order.Descending}})
                        in
                            tbl2[Timer]{0} - tbl2[Timer]{1}
            },

            {"Steps", each  
  
                        let
                            tbl3 = Table.SelectRows(_,each _[StageID] = 1),
                            y = tbl3[Timer]{0},
                            timeList = List.Accumulate(tbl3[Timer],[prev = y, Result={}],(s,c)=>
                                            if s[Result] = {} then [Result={c-y}]
                                            else if List.Count(s[Result]) = 1 then [prev=c,  Result = s[Result] & {c - y}]
                                            else  [Result = s[Result] & {c - s[prev]} , prev = c]
                                        )    
                        in
                            Text.Combine(List.Skip(List.Transform(timeList[Result], (n) => Text.From(Number.Round(n*60*60*24,0))& "s" )),", ")
            }
         }
    ),
    cTypes = Table.TransformColumnTypes(result,{{"TotalDur", type time}, {"Duration1_10", type time}})

in
    cTypes



Book1
ABCD
1ProcessIDTotalDurDuration1_10Steps
24895500200:06:2000:05:2120s, 29s, 71s, 27s, 43s, 44s, 44s, 20s, 23s
34855580400:10:4200:07:2616s, 41s, 41s, 176s, 33s, 38s, 36s, 32s, 32s
448a1840400:08:1700:05:3535s, 36s, 40s, 44s, 36s, 33s, 37s, 35s, 38s
548a1a80600:06:3700:04:4530s, 27s, 45s, 37s, 28s, 34s, 28s, 32s, 24s
648b8a00600:07:4100:04:3933s, 32s, 32s, 31s, 29s, 24s, 43s, 28s, 28s
Table1 (2)
 
Upvote 0
Solution
@JEC hi apologies for not getting back to you earlier I gave myself a 2 day pass away from excel
I was going to put my programming hat on (not M code I might add) and try and make a few adjustments As follows
Make the base for the timer tbl3 [Timer]{0} the last entry of stage0 timer, so that will give 10 timers for stage=1 as it’s a sequential process, an oversight on my part
For the 10 time slices I am thinking of dropping the “s” and creating 10 columns so I can play further tunes on the slices, MIN,MAX,AVERAGE for each slice, not decided on that yet but having the option later on would be good. I guess this would just be a split of the steps column but I am sure there is a more elegant way
I am a programmer of many years but this M code is quite an abstract beast once you get outside the button pushing in the interface
 
Upvote 0
Ok great! You will get there🙂
Cheers
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top