help with converting time formula into power query

bbrimberry

New Member
Joined
Mar 23, 2016
Messages
34
Could someone could help me out with a quick power query formula?

I have spreadshet formula in E that calculates arrival time based on previous store durations.
the data is sorted by day and name of driver.
if the day and name of driver are the same the formula keeps adding until it see's a different driver.

I would like to calculate this in power query if possible.



Sample 7-23-2021.xlsx
ABCDE
1StoreDayNameDurationArrival Time
2Store 1MondayFred1508:00:00
3Store 2 MondayFred1008:16:00
4Store 20MondayHolly508:00:00
5Store 21MondayHolly508:06:00
6Store 22MondayHolly508:12:00
7Store 23MondayHolly508:18:00
8Store 24MondayHolly508:24:00
9Store 25MondayHolly508:30:00
10Store 26MondayHolly508:36:00
11Store 27MondayHolly508:42:00
12Store 28MondayHolly508:48:00
13Store 29MondayHolly508:54:00
14Store 30MondayHolly509:00:00
15Store 10MondayLogan508:00:00
16Store 11MondayLogan508:06:00
17Store 12MondayLogan508:12:00
18Store 13MondayLogan508:18:00
19Store 14MondayLogan508:24:00
20Store 15MondayLogan508:30:00
21Store 16MondayLogan508:36:00
22Store 17MondayLogan2008:42:00
23Store 18MondayLogan509:03:00
24Store 19MondayLogan1509:09:00
25Store 3MondayLogan509:25:00
26Store 4MondayLogan509:31:00
27Store 5MondayLogan509:37:00
28Store 6MondayLogan509:43:00
29Store 7MondayLogan509:49:00
30Store 8MondayLogan509:55:00
31Store 9MondayLogan1010:01:00
32Store 31TuesdayFred508:00:00
33Store 32TuesdayFred508:06:00
34Store 33TuesdayFred508:12:00
35Store 34TuesdayFred508:18:00
36Store 35TuesdayFred508:24:00
37Store 36TuesdayFred508:30:00
38Store 37TuesdayFred508:36:00
39Store 38TuesdayFred508:42:00
40Store 39TuesdayFred508:48:00
41Store 40TuesdayFred508:54:00
42Store 41TuesdayFred509:00:00
43Store 59TuesdayHolly508:00:00
44Store 60TuesdayHolly508:06:00
45Store 61TuesdayHolly508:12:00
46Store 62TuesdayHolly508:18:00
47Store 63TuesdayHolly508:24:00
48Store 64TuesdayHolly508:30:00
49Store 65TuesdayHolly508:36:00
50Store 56TuesdayLogan508:00:00
51Store 57TuesdayLogan508:06:00
52Store 58TuesdayLogan508:12:00
53Store 66TuesdayMary508:00:00
54Store 67TuesdayMary508:06:00
55Store 68TuesdayMary508:12:00
56Store 69TuesdayMary508:18:00
57Store 70TuesdayMary508:24:00
58Store 71TuesdayMary508:30:00
59Store 72TuesdayMary508:36:00
60Store 73TuesdayMary508:42:00
61Store 74TuesdayMary508:48:00
62Store 75TuesdayMary508:54:00
63Store 76TuesdayMary509:00:00
64Store 77TuesdayMary509:06:00
65Store 78TuesdayMary509:12:00
66Store 79TuesdayMary509:18:00
67Store 80TuesdayMary509:24:00
68Store 81TuesdayMary509:30:00
69Store 82TuesdayMary509:36:00
70Store 83TuesdayMary509:42:00
71Store 84TuesdayMary509:48:00
72Store 85TuesdayMary509:54:00
73Store 86TuesdayMary510:00:00
74Store 87TuesdayMary510:06:00
75Store 88TuesdayMary510:12:00
76Store 89TuesdayMary510:18:00
77Store 90TuesdayMary510:24:00
78Store 91TuesdayMary510:30:00
79Store 92TuesdayMary510:36:00
80Store 93TuesdayMary510:42:00
81Store 94TuesdayMary510:48:00
82Store 42TuesdayMike508:00:00
83Store 43TuesdayMike508:06:00
84Store 44TuesdayMike508:12:00
85Store 45TuesdayMike508:18:00
86Store 46TuesdayMike508:24:00
87Store 47TuesdayMike508:30:00
88Store 48TuesdayMike508:36:00
89Store 49TuesdayMike508:42:00
90Store 50TuesdayMike508:48:00
91Store 51TuesdayMike508:54:00
92Store 52TuesdayMike509:00:00
93Store 53TuesdayMike509:06:00
94Store 54TuesdayMike509:12:00
95Store 55TuesdayMike509:18:00
96Store 100WednesdayBill508:00:00
97Store 101WednesdayBill508:06:00
98Store 102WednesdayBill508:12:00
99Store 103WednesdayBill508:18:00
100Store 104WednesdayBill508:24:00
101Store 105WednesdayBill508:30:00
102Store 106WednesdayBill508:36:00
103Store 107WednesdayBill508:42:00
104Store 108WednesdayBill508:48:00
105Store 109WednesdayBill508:54:00
106Store 110WednesdayBill509:00:00
107Store 111WednesdayBill509:06:00
108Store 112WednesdayBill509:12:00
109Store 113WednesdayBill509:18:00
110Store 114WednesdayBill509:24:00
111Store 115WednesdayBill509:30:00
112Store 116WednesdayBill509:36:00
113Store 117WednesdayBill509:42:00
114Store 118WednesdayBill509:48:00
115Store 119WednesdayBill509:54:00
116Store 120WednesdayBill510:00:00
117Store 121WednesdayBill510:06:00
118Store 122WednesdayBill510:12:00
119Store 123WednesdayBill510:18:00
120Store 124WednesdayBill510:24:00
121Store 125WednesdayBill510:30:00
122Store 126WednesdayBill510:36:00
123Store 127WednesdayBill510:42:00
124Store 128WednesdayBill510:48:00
125Store 129WednesdayBill510:54:00
126Store 130WednesdayBill511:00:00
127Store 95WednesdayBill511:06:00
128Store 96WednesdayBill511:12:00
129Store 97WednesdayBill511:18:00
130Store 98WednesdayBill511:24:00
131Store 99WednesdayBill511:30:00
132Store 131WednesdayFred508:00:00
133Store 132WednesdayFred508:06:00
134Store 133WednesdayFred508:12:00
135Store 134WednesdayFred508:18:00
136Store 135WednesdayFred508:24:00
137Store 136WednesdayFred508:30:00
138Store 137WednesdayFred508:36:00
139Store 138WednesdayFred508:42:00
140Store 139WednesdayFred508:48:00
141Store 140WednesdayFred508:54:00
142Store 141WednesdayFred509:00:00
143Store 142WednesdayFred509:06:00
144Store 143WednesdayFred509:12:00
145Store 144WednesdayFred509:18:00
146Store 145WednesdayFred509:24:00
147Store 146WednesdayFred509:30:00
148Store 147WednesdayFred509:36:00
149Store 177WednesdayHolly508:00:00
150Store 178WednesdayHolly508:06:00
151Store 179WednesdayHolly508:12:00
152Store 180WednesdayHolly508:18:00
153Store 181WednesdayHolly508:24:00
154Store 182WednesdayHolly508:30:00
155Store 183WednesdayHolly508:36:00
156Store 184WednesdayHolly508:42:00
157Store 185WednesdayHolly508:48:00
158Store 186WednesdayHolly508:54:00
159Store 187WednesdayHolly509:00:00
160Store 188WednesdayHolly509:06:00
161Store 189WednesdayHolly509:12:00
162Store 190WednesdayHolly509:18:00
163Store 191WednesdayHolly509:24:00
164Store 157WednesdayLogan508:00:00
165Store 158WednesdayLogan508:06:00
166Store 159WednesdayLogan508:12:00
167Store 160WednesdayLogan508:18:00
168Store 161WednesdayLogan508:24:00
169Store 162WednesdayLogan508:30:00
170Store 163WednesdayLogan508:36:00
171Store 164WednesdayLogan508:42:00
172Store 165WednesdayLogan508:48:00
173Store 166WednesdayLogan508:54:00
174Store 167WednesdayLogan509:00:00
175Store 168WednesdayLogan509:06:00
176Store 169WednesdayLogan509:12:00
177Store 170WednesdayLogan509:18:00
178Store 171WednesdayLogan509:24:00
179Store 172WednesdayLogan509:30:00
180Store 173WednesdayLogan509:36:00
181Store 174WednesdayLogan509:42:00
182Store 175WednesdayLogan509:48:00
183Store 176WednesdayLogan509:54:00
184Store 148WednesdayMike508:00:00
185Store 149WednesdayMike508:06:00
186Store 150WednesdayMike508:12:00
187Store 151WednesdayMike508:18:00
188Store 152WednesdayMike508:24:00
189Store 153WednesdayMike508:30:00
190Store 154WednesdayMike508:36:00
191Store 155WednesdayMike508:42:00
192Store 156WednesdayMike508:48:00
Stores
Cell Formulas
RangeFormula
E2:E192E2=IF(C2<>C1,TIME(8,0,0),E1+TIME(0,D1+1,0 ))
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Please try


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Grouped = Table.Group(Source, {"Day", "Name"}, {{"T", each let
        a = Table.Buffer(Table.AddIndexColumn(_,"in"))
        in Table.AddColumn(a,"Arrival", each if [in] = 0 then #time(8,0,0) else  #time(8,0,0)+#duration(0,0, List.Sum(Table.SelectRows(a, (a)=> a[in] < [in])[Duration])+[in],0) )
    }},0),
    Combine = Table.Combine(Grouped[T],Table.ColumnNames(Source)&{"Arrival"})
in
    Combine

Book1
GHIJKL
1StoreDayNameDurationArrival TimeArrival
2Store 1MondayFred158:008:00
3Store 2 MondayFred108:168:16
4Store 20MondayHolly58:008:00
5Store 21MondayHolly58:068:06
6Store 22MondayHolly58:128:12
7Store 23MondayHolly58:188:18
8Store 24MondayHolly58:248:24
9Store 25MondayHolly58:308:30
10Store 26MondayHolly58:368:36
11Store 27MondayHolly58:428:42
12Store 28MondayHolly58:488:48
13Store 29MondayHolly58:548:54
14Store 30MondayHolly59:009:00
15Store 10MondayLogan58:008:00
16Store 11MondayLogan58:068:06
17Store 12MondayLogan58:128:12
18Store 13MondayLogan58:188:18
19Store 14MondayLogan58:248:24
20Store 15MondayLogan58:308:30
21Store 16MondayLogan58:368:36
22Store 17MondayLogan208:428:42
23Store 18MondayLogan59:039:03
24Store 19MondayLogan159:099:09
25Store 3MondayLogan59:259:25
26Store 4MondayLogan59:319:31
27Store 5MondayLogan59:379:37
28Store 6MondayLogan59:439:43
29Store 7MondayLogan59:499:49
30Store 8MondayLogan59:559:55
31Store 9MondayLogan1010:0110:01
32Store 31TuesdayFred58:008:00
33Store 32TuesdayFred58:068:06
34Store 33TuesdayFred58:128:12
35Store 34TuesdayFred58:188:18
36Store 35TuesdayFred58:248:24
37Store 36TuesdayFred58:308:30
38Store 37TuesdayFred58:368:36
39Store 38TuesdayFred58:428:42
40Store 39TuesdayFred58:488:48
41Store 40TuesdayFred58:548:54
42Store 41TuesdayFred59:009:00
43Store 59TuesdayHolly58:008:00
44Store 60TuesdayHolly58:068:06
45Store 61TuesdayHolly58:128:12
46Store 62TuesdayHolly58:188:18
47Store 63TuesdayHolly58:248:24
48Store 64TuesdayHolly58:308:30
49Store 65TuesdayHolly58:368:36
50Store 56TuesdayLogan58:008:00
51Store 57TuesdayLogan58:068:06
52Store 58TuesdayLogan58:128:12
53Store 66TuesdayMary58:008:00
54Store 67TuesdayMary58:068:06
55Store 68TuesdayMary58:128:12
56Store 69TuesdayMary58:188:18
57Store 70TuesdayMary58:248:24
58Store 71TuesdayMary58:308:30
59Store 72TuesdayMary58:368:36
60Store 73TuesdayMary58:428:42
61Store 74TuesdayMary58:488:48
62Store 75TuesdayMary58:548:54
63Store 76TuesdayMary59:009:00
64Store 77TuesdayMary59:069:06
65Store 78TuesdayMary59:129:12
66Store 79TuesdayMary59:189:18
67Store 80TuesdayMary59:249:24
68Store 81TuesdayMary59:309:30
69Store 82TuesdayMary59:369:36
70Store 83TuesdayMary59:429:42
71Store 84TuesdayMary59:489:48
72Store 85TuesdayMary59:549:54
73Store 86TuesdayMary510:0010:00
74Store 87TuesdayMary510:0610:06
75Store 88TuesdayMary510:1210:12
76Store 89TuesdayMary510:1810:18
77Store 90TuesdayMary510:2410:24
78Store 91TuesdayMary510:3010:30
79Store 92TuesdayMary510:3610:36
80Store 93TuesdayMary510:4210:42
81Store 94TuesdayMary510:4810:48
82Store 42TuesdayMike58:008:00
83Store 43TuesdayMike58:068:06
84Store 44TuesdayMike58:128:12
85Store 45TuesdayMike58:188:18
86Store 46TuesdayMike58:248:24
87Store 47TuesdayMike58:308:30
88Store 48TuesdayMike58:368:36
89Store 49TuesdayMike58:428:42
90Store 50TuesdayMike58:488:48
91Store 51TuesdayMike58:548:54
92Store 52TuesdayMike59:009:00
93Store 53TuesdayMike59:069:06
94Store 54TuesdayMike59:129:12
95Store 55TuesdayMike59:189:18
96Store 100WednesdayBill58:008:00
97Store 101WednesdayBill58:068:06
98Store 102WednesdayBill58:128:12
99Store 103WednesdayBill58:188:18
100Store 104WednesdayBill58:248:24
101Store 105WednesdayBill58:308:30
102Store 106WednesdayBill58:368:36
103Store 107WednesdayBill58:428:42
104Store 108WednesdayBill58:488:48
105Store 109WednesdayBill58:548:54
106Store 110WednesdayBill59:009:00
107Store 111WednesdayBill59:069:06
108Store 112WednesdayBill59:129:12
109Store 113WednesdayBill59:189:18
110Store 114WednesdayBill59:249:24
111Store 115WednesdayBill59:309:30
112Store 116WednesdayBill59:369:36
113Store 117WednesdayBill59:429:42
114Store 118WednesdayBill59:489:48
115Store 119WednesdayBill59:549:54
116Store 120WednesdayBill510:0010:00
117Store 121WednesdayBill510:0610:06
118Store 122WednesdayBill510:1210:12
119Store 123WednesdayBill510:1810:18
120Store 124WednesdayBill510:2410:24
121Store 125WednesdayBill510:3010:30
122Store 126WednesdayBill510:3610:36
123Store 127WednesdayBill510:4210:42
124Store 128WednesdayBill510:4810:48
125Store 129WednesdayBill510:5410:54
126Store 130WednesdayBill511:0011:00
127Store 95WednesdayBill511:0611:06
128Store 96WednesdayBill511:1211:12
129Store 97WednesdayBill511:1811:18
130Store 98WednesdayBill511:2411:24
131Store 99WednesdayBill511:3011:30
132Store 131WednesdayFred58:008:00
133Store 132WednesdayFred58:068:06
134Store 133WednesdayFred58:128:12
135Store 134WednesdayFred58:188:18
136Store 135WednesdayFred58:248:24
137Store 136WednesdayFred58:308:30
138Store 137WednesdayFred58:368:36
139Store 138WednesdayFred58:428:42
140Store 139WednesdayFred58:488:48
141Store 140WednesdayFred58:548:54
142Store 141WednesdayFred59:009:00
143Store 142WednesdayFred59:069:06
144Store 143WednesdayFred59:129:12
145Store 144WednesdayFred59:189:18
146Store 145WednesdayFred59:249:24
147Store 146WednesdayFred59:309:30
148Store 147WednesdayFred59:369:36
149Store 177WednesdayHolly58:008:00
150Store 178WednesdayHolly58:068:06
151Store 179WednesdayHolly58:128:12
152Store 180WednesdayHolly58:188:18
153Store 181WednesdayHolly58:248:24
154Store 182WednesdayHolly58:308:30
155Store 183WednesdayHolly58:368:36
156Store 184WednesdayHolly58:428:42
157Store 185WednesdayHolly58:488:48
158Store 186WednesdayHolly58:548:54
159Store 187WednesdayHolly59:009:00
160Store 188WednesdayHolly59:069:06
161Store 189WednesdayHolly59:129:12
162Store 190WednesdayHolly59:189:18
163Store 191WednesdayHolly59:249:24
164Store 157WednesdayLogan58:008:00
165Store 158WednesdayLogan58:068:06
166Store 159WednesdayLogan58:128:12
167Store 160WednesdayLogan58:188:18
168Store 161WednesdayLogan58:248:24
169Store 162WednesdayLogan58:308:30
170Store 163WednesdayLogan58:368:36
171Store 164WednesdayLogan58:428:42
172Store 165WednesdayLogan58:488:48
173Store 166WednesdayLogan58:548:54
174Store 167WednesdayLogan59:009:00
175Store 168WednesdayLogan59:069:06
176Store 169WednesdayLogan59:129:12
177Store 170WednesdayLogan59:189:18
178Store 171WednesdayLogan59:249:24
179Store 172WednesdayLogan59:309:30
180Store 173WednesdayLogan59:369:36
181Store 174WednesdayLogan59:429:42
182Store 175WednesdayLogan59:489:48
183Store 176WednesdayLogan59:549:54
184Store 148WednesdayMike58:008:00
185Store 149WednesdayMike58:068:06
186Store 150WednesdayMike58:128:12
187Store 151WednesdayMike58:188:18
188Store 152WednesdayMike58:248:24
189Store 153WednesdayMike58:308:30
190Store 154WednesdayMike58:368:36
191Store 155WednesdayMike58:428:42
192Store 156WednesdayMike58:488:48
Sheet1
 
Upvote 0
Solution
Wow!
Yes that solved my issue. thank you very much!

I do have one question. Does the table have to be sorted first for the solution to work?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

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