Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating number of people working per hour

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I am attempting to make a formula to calculate the total number of people scheduled per hour based on their start and end times. It seems to work fine until there is a shift that crosses over midnight. I have attached a quick sample of what i am seeing with my formulas and wondering if someone can help me get the correct calculations.

Thank you in advance for any help anyone can offer.

Paul
 
 https://files.engineering.com/getfile.aspx?folder=2baa4a64-aac3-40f5-a638-a99d2d48cd8b&file=test_Shifts.xlsx
hi,

1. Your TIME value in G6 is 1/1/1900 7:00:00 AM and correctly so! Every TIME value in this list ought to have a DATE component in order to accommodate the midnight shift to the next day.

2. So the value in G7 and following needs to be
[tt]
G7: =G6+TIME(1,0,0)
[/tt]
...and COPY N PASTE down.

3. The COUNTIFS formula then is (using named ranges)
[tt]
H6: =COUNTIFS(shift_Start,"<="&G6-INT(G6),Shift_End,">="&G6-INT(G6))
[/tt]

BTW, I greatly prefer using SUMPRODUCT()
[tt]
H6: =SUMPRODUCT((shift_Start<=G6-INT(G6))*(Shift_End>=G6-INT(G6)))
[/tt]




Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
 https://files.engineering.com/getfile.aspx?folder=1372ad1e-9ad9-4665-8155-6ee524077a23&file=Copy_of_test_Shifts.xlsx
I saw yet another issue where the Shift End crosses the day.

So I added another column, Shift End1 with the following formula...
[tt]
E6: =IF(C6>D6,1,0)+D6
[/tt]

This will only work under this restriction: That ALL Shift Start times are for the same day, from midnight (12:00 AM to 11:59 PM)

Then...
[tt]
H6: =SUMPRODUCT((shift_Start<=G6-INT(G6))*(Shift_End[highlight #FCE94F]1[/highlight]>=G6-INT(G6)))
[/tt]
And the other thing I did was use Excel's Series feature by entering [highlight #FCE94F]7:[/highlight] and [highlight #FCE94F]8:[/highlight] in G6 & G7 respectively and then SELECTING G6 & G7 and DRAGGING the handle down thru G29. This will auto increment each cell and add a date value at midnight.

File attached.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
 https://files.engineering.com/getfile.aspx?folder=471177e3-7368-4467-a489-86ca2d58eb6e&file=Copy_of_test_Shifts.xlsx
Thanks Skip, I just got back around to trying to figure this out again.....if you look at the file you sent back to me I think there is still an issue. Lets focus just on the 1:00 am time slot.....It shows 2 people working when it should be 9 people working at 1 am. Am I looking at something incorrectly?

Really appreciate your help here!

Thank you!

Paul
 
I had two different things going in my head. Since Shift_End1 accounts for the times in the next day, there’s no need to remove thenext day date via INT().

This one should work better. I count 7 by hand and via formula.

H6: =SUMPRODUCT((shift_Start<=G6)*(Shift_End1>=G6))

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
 https://files.engineering.com/getfile.aspx?folder=bdf0dc26-f12d-428c-be40-c7f7ace59e5a&file=Copy2_of_Copy_of_test_Shifts.xlsx
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top