Formula Help - Calculate Occurrences between two times

leighjones123

New Member
Joined
Aug 12, 2011
Messages
49
Office Version
  1. 365
Platform
  1. MacOS
Hi all. Looking for some help with a formula to do what I need... For whatever reason, I can't seem to find the right COUNTIFS.

In ColA I have a start time (for a booking)
In ColB is the end time

I'm trying to create a table which shows me how many bookings are active within the times set.

My data example...

Start TimeEnd TimeBooking Name
12:00​
14:00​
Mr A Smith
12:30​
14:30​
Mr B Smith
13:00​
15:00​
Mr C Smith
16:00​
18:00​
Mr D Smith

My required table (with the end result)...

Start TimeEnd TimeBookings Active
12:00​
12:29​
1​
12:30​
12:59​
2​
13:00​
13:29​
3​
13:30​
13:59​
3​
14:00​
14:29​
2​
14:30​
14:59​
1​
15:00​
15:29​
0​
15:30​
15:59​
0​
16:00​
16:29​
1​
16:30​
16:59​
1​
17:00​
17:29​
1​
17:30​
17:59​
1​


Just to add context... this is to help me to see how many tables are in use within my restaurant at what times... so I can effectively plan staffing.
Unfortunately, my booking system doesn't automatically give me the data I need.

I've been able to work out how to find out how many tables/customers are arriving within a particular time window... but this doesn't tell me exactly how many total customers I've got in the restaurant within a particular time window.

Hope anyone can help

Best
Leigh
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

However, see if this is what you want.

20 12 13.xlsm
ABC
1Start TimeEnd TimeBooking Name
212:0014:00Mr A Smith
312:3014:30Mr B Smith
413:0015:00Mr C Smith
516:0018:00Mr D Smith
6
7
8Start TimeEnd TimeBookings Active
912:0012:291
1012:3012:592
1113:0013:293
1213:3013:593
1314:0014:292
1414:3014:591
1515:0015:290
1615:3015:590
1716:0016:291
1816:3016:591
1917:0017:291
2017:3017:591
Bookings
Cell Formulas
RangeFormula
C9:C20C9=COUNTIFS(B$2:B$5,">"&A9,A$2:A$5,"<"&B9)
 
Upvote 0
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

However, see if this is what you want.

20 12 13.xlsm
ABC
1Start TimeEnd TimeBooking Name
212:0014:00Mr A Smith
312:3014:30Mr B Smith
413:0015:00Mr C Smith
516:0018:00Mr D Smith
6
7
8Start TimeEnd TimeBookings Active
912:0012:291
1012:3012:592
1113:0013:293
1213:3013:593
1314:0014:292
1414:3014:591
1515:0015:290
1615:3015:590
1716:0016:291
1816:3016:591
1917:0017:291
2017:3017:591
Bookings
Cell Formulas
RangeFormula
C9:C20C9=COUNTIFS(B$2:B$5,">"&A9,A$2:A$5,"<"&B9)
thanks so much Peter, this seems to work great. Thanks for the tip re updating my account information - I'll do that :)
 
Upvote 0
Peter,

Could I ask a follow-on question?

So this works perfectly for the count of how many bookings (tables) I'll have in use within any given time window. I adapted the ranges to fit my acutal data (I simplified it above for ease).

In my data, I've also got a Column which shows how many people are within that booking (customers).
To get this information into my table, I figured I could use a SUMIFS instead of a COUNTIFS - but it doesn't seem to work as expected. At the earlier time slots, it's giving me the total people for the day.

Any ideas how I could get around this?

Best,
Leigh
1607826420194.png


What I tried:

Excel Formula:
=SUMIFS(SUN!$G$2:$G$78,SUN!$AA$2:$AA$78,">"&W6,SUN!$E$2:$E$78,"<"&X6)
 
Upvote 0
thanks so much Peter, this seems to work great.
Good news! :)

Thanks for the tip re updating my account information - I'll do that
Thanks for updating your profile. (y)

Now for the next tip: I suggest that you investigate XL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be. For example, I cannot see what columns/rows the info in post #4 is in. Nor could I copy it if I wanted to use for testing. :)

Try the SUMIFS given in column D below. Also, now that we know you have Excel 365, alternative suggestions for both results are given in columns E:F. See how they go.

20 12 13.xlsm
ABCDEF
1Start TimeEnd TimeBooking NameCustomers
212:0014:00Mr A Smith4
312:3014:30Mr B Smith10
413:0015:00Mr C Smith5
516:0018:00Mr D Smith13
6
7
8Start TimeEnd TimeTablesCustomersTablesCustomers
912:0012:291414
1012:3012:59214214
1113:0013:29319319
1213:3013:59319319
1314:0014:29215215
1414:3014:591515
1515:0015:290000
1615:3015:590000
1716:0016:29113113
1816:3016:59113113
1917:0017:29113113
2017:3017:59113113
Bookings
Cell Formulas
RangeFormula
C9:C20C9=COUNTIFS(B$2:B$5,">"&A9,A$2:A$5,"<"&B9)
D9:D20D9=SUMIFS(D$2:D$5,B$2:B$5,">"&A9,A$2:A$5,"<"&B9)
E9:E20E9=COUNT(FILTER(D$2:D$5,(B$2:B$5>A9)*(A$2:A$5<B9)))
F9:F20F9=SUM(FILTER(D$2:D$5,(B$2:B$5>A9)*(A$2:A$5<B9),0))
 
Upvote 0
Solution
Thank you again Peter, that works great. Thanks for the tip re XL2BB also, I'll take a look :)
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,236
Messages
6,123,799
Members
449,127
Latest member
Cyko

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