Identifying work crew on shift by timestamp provided in productivity report.

MattyJimmy

New Member
Joined
Apr 20, 2018
Messages
5
I receive a report which details the time a truckload of material was dumped as a timestamp. I am wanting to write a formula which interrogates the timestamp and can then identify which work crew was on shift at the time the load was dumped. Shift details are as follows:

4 crews: A, B, C, D. Each works 7x12 hour shifts, then goes on break. If a crew is working day shift for 7 days, they go on break for 7 days but not 7*24 hours, as they come back in on night shift after their break, with their counterparts coming back in on day shift.

Whilst they were on break, the other two crews were working day shift/night shift. example below:

On 28 March at 07:00, A crew started their 7 day swing. Working from 07:00 until 18:59:59, at 19:00 B crew started shift, working through until 06:59:59 the following day.

These crews continued to rotate until B crew finished night shift at 06:59:59 on 05 April. Both A and B crew then went on break.

At 07:00 on 05 April, D crew started shift, they worked until 18:59:59, at 19:00, C crew started shift, working through until 06:59:59 the following day.

and so on. The trick bit is when C and D crew go on break, B crew comes in on Day shift, with A crew coming back in on night shift.

Wow, thanks for reading this far! I figure I should be able to divide the timestamp by a number, and then depending on if the result is between a range of values we should be able to see what two crews are working, i.e. A/B or C/D, but am not sure how to identify it down to the crew on day or night shift, especially seeing as they go from days to nights to days and so on.

Any help would be greatly appreciated.

Cheers,

Mat

P.S. This data is then sucked into a PowerQuery query, so if it is easier to sort out in PowerQuery please let me know! :)
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,073
The tricky part in matching timestamps is the morning when the A-B crews are relieved by the C-D crews. Your dates are a little confusing: if A-crew starts at 28-Mar 07:00 and B-Crew at 28-Mar 19:00, C-crew should start at 07:00 on 04-Apr.

Anyhow, this seems to work, just correct the dates:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="background-color: #EBEBEB;;">Week</td><td style="text-align: center;background-color: #EBEBEB;;">07:00</td><td style="text-align: center;background-color: #EBEBEB;;">19:00</td><td style="text-align: right;;"></td><td style="border-right: 1px solid black;background-color: #EBEBEB;;">Timestamp</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">04/19/2018 06:00</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">29-Mar-18</td><td style="text-align: center;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">A</td><td style="text-align: center;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">B</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="border-right: 1px solid black;background-color: #EBEBEB;;">Crew</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #FFF5D7;;">A</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">05-Apr-18</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">C</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">D</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-top: 1px solid black;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">12-Apr-18</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">B</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">A</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">19-Apr-18</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">D</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">C</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">26-Apr-18</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">A</td><td style="text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">B</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">F2</th><td style="text-align:left">=INDEX(<font color="Blue">B2:C5, MATCH(<font color="Red">F1-(<font color="Green">HOUR(<font color="Purple">F1</font>)< 7</font>), A2:A5</font>), 1+OR(<font color="Red">HOUR(<font color="Green">F1</font>)< 7, HOUR(<font color="Green">F1</font>)>19</font>)</font>)</td></tr></tbody></table></td></tr></table><br />
 
Last edited:

MattyJimmy

New Member
Joined
Apr 20, 2018
Messages
5
Fantastic, this is working great. I have expanded the indexed cells to span the whole year (just by dragging down) as with the dates and have ran a few tests which seem to work perfectly. I like the idea of using index match to solve the problem. As you may have been able to tell, I was thinking of a mathematical answer to the question but this works great. (Yes I know this is still mathematical, but you know what I mean!). Thanks again for the help.
P.S. Hahaha, yes I had the dates out by 1 day, but oddly enough D crew really does start before C crew. The rotation goes A, B, D, C. I presume it is because we are Australian and that is the closest we could get to resemble AC/DC!! :P Thanks again.
 

MattyJimmy

New Member
Joined
Apr 20, 2018
Messages
5
Found one issue, changed the final part of the formula to >18, as it seems to include anything up to 19.99999999999999999 repeater as 19, therefore the function was identifying all timestamps before 8pm as still on dayshift. (I hope that makes sense!)
 

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,073
I'm happy the lookup table and formula work for you.

It's good that you found the formula error. I tested values on either side of midnight and at the morning shift change; I forgot to test the evening shift change. ">=19" would also correct my mistake and may be more self-explanatory when you look at the formula two weeks from now.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,926
Messages
5,447,336
Members
405,447
Latest member
WPY

This Week's Hot Topics

Top