A worksheet I am dealing with has the following:
A1:A2000 -> 4 digit ID number
B1:B2000 -> Calendar shift date
C1:C2000 -> Shift Ident, 1 = dayshift, 2 = nightshift.
D1:D2000 -> Start timestamp
E1:E2000 -> End Timestamp
The data applies to start and end timestamps of shift change times at a mine site for haul trucks and other mine equipment. The computer system that records the data starts its shift change at 7:00 AM and 7:00 PM each day. The "Start Timestamp" is when the operator left their truck at the end of the shift, and the "End Timestamp" is when the operator gets on their truck. The problem is that in the middle of that time slot, the computer does its shift change, adding another start and end timestamp to the system, so a shift change that started at 6:40 AM, and finished at 7:24 AM shows in 2 entries:
Start timestamp of 6:40 AM, End timestamp of 7:00 AM, and another Start Timestamp of 7:00 AM, followed by an End timestamp of 7:24 AM. This creates 2 entries to sort through. The shift date changes over at 7:00 AM every day.
I am trying to write 2 formulas, one to give me the shift start time, or time after 7:00 AM or 7:00 PM (depending on the shift ident), the other to give me the end shift time, or time before 7:00 AM or 7:00 PM, again depending on the shift ident.
Here is a short sample of my data, and what I am trying to output. Keep in mind this is only a small sample, The data that comes in is unsorted, and in thousands of rows.
Data is as follows:
"Sheet1"
A1=2431, B1=05/1/2010 0:00, C1=1, D1=7:00, E1=7:24
A2=2431, B2=05/1/2010 0:00, C1=1, D1=18:40 E2=19:00
"Sheet2"
A1=2431, B1=05/1/2010 0:00, C1=1
And I am trying to calculate D1, and E1 on Sheet2. D1 is start time, E1 is end time.
I enter in the following formula into Sheet2, cell D1:
=INDEX(Sheet1!D1:D2,MATCH(Sheet2!A1&Sheet2!B1&Sheet2!C1,Sheet1!A1:A2&Sheet1!B1:B2&Sheet1!C1:C2,0))
The expected result is 7:24 and I get 7:24
Then I enter the following formula into Sheet2, cell E1:
=INDEX(Sheet1!E1:E2,MATCH(Sheet2!A1&Sheet2!B1&Sheet2!C1,Sheet1!A1:A2&Sheet1!B1:B2&Sheet1!C1:C2,0))
The expected result is 18:40, I get 7:00.
So the index and match is giving me the first result it comes to. I can create a formula to make the 7:00 and 19:00 cells blank, but then the formula just gives me 0:00 instead of the 18:40 that I want. Is there a way to say "if(ISBLANK...." or another way perhaps? I have spent a couple of days on this now, and am lost.
Any help on this would be much appreciated.
Bookmarks