09-05-2020 12:17 AM
09-05-2020 12:17 AM
I was recently working on a spreadsheet to review the overall coverage where I entered the numbers manually by looking at shifts for each employee for the entire week. I was thinking of applying a function which can distribute the hours post 00:00 hours into the next day similarly, Sunday hours into Monday.
Hope, attached spreadsheet/image will help you answer my question to be able to assist.
I tried applying COUNT IF, however, i couldn't figure out distributing it to the next day.
09-05-2020 03:34 AM
@ikawaljeetsingh Don't have a ready solution for your specific example, since calculating with start and end times ("hh:mm") contained in text strings becomes very difficult, especially when shift end time goes beyond midnight. Though, I'm offering an example that may inspire you to choose a different approach by using numbers, rather than time values. Since your shifts always seem to last 11 hours, it becomes much easier.
The one sheet in this workbook does the calculation of the number of employees per time slot per day. It does NOT create the a fancy summary per week, but all the elements are there.
09-05-2020 08:49 AM
Here is Power Query solution. Result is
- source data is named as Range;
- query it, unpivot shifts, split on start and end
- filter on ThisDay and NextDay. If overnight shift, ThisDay ends at 24:00, NextDay starts at 00:00 and for it change Day name on next weekday
- generate 30-minutes lists for each Start and End, expand it and Pivot on weekday counting employees
09-05-2020 09:09 AM
09-05-2020 09:10 AM
09-05-2020 09:13 AM
09-05-2020 09:21 AM - edited 09-05-2020 09:22 AM
@ikawaljeetsingh Just wondering if your example really reflects what you want/need. Now you count the time slots that are carried over from Monday to Tuesday as time slots on the Monday. In my view, when a shift starts on Monday 17:00 and ends 04:00 the next morning it should reflect 4 hours on Tuesday from 00:00 till 04:00. In other words, the early morning slots on a Monday come from shifts that started on the Sunday before and that ran over midnight. But perhaps I misunderstood your requirements.
09-05-2020 09:25 AM
09-05-2020 09:39 AM
@ikawaljeetsingh So, in your example for the Monday, there should be nothing in the early morning time slots as the first shift on Monday starts 6:00 and there is no information on the Sunday before. But again, perhaps I misinterpret your example.
09-05-2020 09:53 AM
Then it would make more sense to start your day from 00:00 and end it at 23:59
Let's say one worker had a shift from 22:00 to 04:00 then from 22:00-23:59 goes to this day and the remainder goes to the next day.
the formula would be much easier.
Best of luck