Allocate between dates to months then summarise by month and year

Robert Davidson

New Member
Joined
Aug 8, 2023
Messages
29
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am seeking help how to split bookings by date and summarising it by month and year. Thus an example of the data is:
StartEnd
Jan-2024​
Feb-2024​
Mar-2024​
Apr-2024​
May-2024​
Jun-2024​
Jul-2024​
Aug-2024​
Sep-2024​
Oct-2024​
Nov-2024​
Dec-2024​
Jan-2025​
Feb-2025​
Mar-2025​
Apr-2025​
15/01/2024​
02/02/2024​
17​
1​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
26/02/2024​
04/03/2024​
0​
4​
3​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
05/04/2024​
06/04/2024​
0​
0​
0​
1​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
06/04/2024​
12/06/2024​
0​
0​
0​
25​
31​
11​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
30/12/2024​
05/01/2025​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
2​
4​
0​
0​
0​
05/09/2024​
12/10/2024​
0​
0​
0​
0​
0​
0​
0​
0​
26​
11​
0​
0​
0​
0​
0​
0​
14/06/2024​
16/06/2024​
0​
0​
0​
0​
0​
2​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
26/02/2025​
04/03/2025​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
3​
3​
0​

I can split the bookings by month using the following formula which is in the Jan 2024 column (second row): =MAX(0,(MIN($B2-1,DATE(YEAR(C$1),MONTH(C$1)+1,0))-MAX($A2,C$1)+1)).
However I would like to generate the following table only using the above Start and End columns and dispense with the remainder of the above columns:

Month
2024​
2025​
Jan​
17​
4​
Feb​
5​
3​
Mar​
3​
3​
Apr​
26​
0​
May​
31​
etc. the table would build into 2026, 2027 etc as more bookings are added
Jun​
13​
Jul​
0​
Aug​
0​
Sep​
26​
Oct​
11​
Nov​
0​
Dec​
2​
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
How about:

Book1
ABCDEFGHIJKLMNOPQR
1StartEndJan-2024Feb-2024Mar-2024Apr-2024May-2024Jun-2024Jul-2024Aug-2024Sep-2024Oct-2024Nov-2024Dec-2024Jan-2025Feb-2025Mar-2025Apr-2025
21/15/20242/2/202417100000000000000
32/26/20243/4/20240430000000000000
44/5/20244/6/20240001000000000000
54/6/20246/12/20240002531110000000000
612/30/20241/5/20250000000000024000
79/5/202410/12/2024000000002611000000
86/14/20246/16/20240000020000000000
92/26/20253/4/20250000000000000330
10
11
12
13Month20242025
14Jan174
15Feb53
16Mar33
17Apr260
18May310
19Jun130
20Jul00
21Aug00
22Sep260
23Oct110
24Nov00
25Dec20
Sheet7
Cell Formulas
RangeFormula
C2:R9C2=MAX(0,(MIN($B2-1,EOMONTH(C$1,0))-MAX($A2,C$1)+1))
B14:C25B14=LET(s,$A$2:$A$9,e,$B$2:$B$9-1,ys,DATE(B13,SEQUENCE(,12),1),ye,EOMONTH(ys,0),m,SEQUENCE(,ROWS(s),,0),c,IF(e<ye,e,ye)-IF(s>ys,s,ys)+1,z,IF(c<0,0,c),TRANSPOSE(MMULT(m,z)))
Dynamic array formulas.
 
Upvote 1
Solution
That's great Eric @Eric W ,

It works fine but would it be possible for the array to expand dynamically as more booking in future years are added? Can the months and years be added dynamically to the formula as row and column headings?
 
Upvote 0
The months don't need to be expanded, since there are only 12 months. The year headings can expand horizontally easily enough. However, the formula itself I don't see how to make it dynamically expand horizontally. Internally it's already a 2D function, and that would make it a 3D function. Standard Excel functions can only handle 2D. It might be possible using some of the newer functions, but I don't have those to work with. Even then, I have a hard time imagining it. Maybe with VBA, but you'd still need a way to initiate the macro.

I'd just put in year headings for the next 10 years, and put the formulas for each of the years under them. If you want, you can use Conditional Formatting to hide any columns that don't have any non-zero values. That way it would appear to dynamically update.
 
Upvote 0
The months don't need to be expanded, since there are only 12 months. The year headings can expand horizontally easily enough. However, the formula itself I don't see how to make it dynamically expand horizontally. Internally it's already a 2D function, and that would make it a 3D function. Standard Excel functions can only handle 2D. It might be possible using some of the newer functions, but I don't have those to work with. Even then, I have a hard time imagining it. Maybe with VBA, but you'd still need a way to initiate the macro.

I'd just put in year headings for the next 10 years, and put the formulas for each of the years under them. If you want, you can use Conditional Formatting to hide any columns that don't have any non-zero values. That way it would appear to dynamically update.
What you have done is great so thank you very much. Robert
 
Upvote 0
Hard to say, it sounds pretty challenging. Do you have a sample of what it would look like? Where that column would go?
 
Upvote 0

Forum statistics

Threads
1,223,856
Messages
6,175,029
Members
452,606
Latest member
jkondrat14

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