How does one collate dates into Monday-Sunday ranges and sum up the data in 2nd Column to those date ranges

Rhothgar

Board Regular
Joined
Sep 24, 2013
Messages
53
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I am sure there will be a simple answer to this but I've been trying to research how to do this and have scratched my head for hours.

I know it's not Get Data>Combine Queries>Merge!

I have a dataset? called TSS and a date range (UK format - DD/MM/YYYY) of 01/01/2021 (This was a Friday) - 31/12/2021 (Also a Friday perchance!)

I would like to be able to quickly collate:-

01/01/2021 - 03/01/2021 then,
04/01/2021 - 10/01/2021 then
11/01/2021 - 17/01/2021 and so on and so forth but ending with
20/12/2021 - 26/12/2021 and
27/12/2021 - 31/12/2021

Technically, if this is too difficult I would be able to add in the preceding days before 01/01/2021 to make a full week's data and 01/01/2022 and 02/01/2022 to make a full week at the year end if it makes the job easier.

Then the data in the TSS column would need to sum up for those date ranges so I have the weekly TSS total.

I have created a basic chart. Ultimately, I would then like to compare it to 2022 data on the same graph so I can see whether more work was done in either year on any given week.

I attach a screenshot of part of the data to give a clearer idea of where I am. Obviously the screenshot shows individual days at present in terms of TSS not having been collated. It can even be in a bar chart format. I am not particularly concerned with how it looks if the chart I have chosen cannot handle what I am trying to achieve.

I have absolutely no idea about VBA or coding or whether that would be needed to achieve what I would like to see. I am only a basic Excel user unlike many of you incredibly clever bods!
 

Attachments

  • 1656763697699.png
    1656763697699.png
    165.8 KB · Views: 36

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
How the output look like?
one column with week start, next column is week end, and one column with week sum?
 
Upvote 0
How the output look like?
one column with week start, next column is week end, and one column with week sum?
No. I want it to look like the chart in he image but the sum of TSS for each week shown as the cumulative total for that week only.

So about 273 for 04/01 - 10/01 approx. (rough mental calc in my head)
 
Upvote 0
The chart needs a new source, doesn't it? I were asking about a new source (output)
 
Upvote 0
Yes. Probably but I have the daily data. I just selected both columns to create the chart.

Hence the post about how to collate the data into weekly data?
 
Upvote 0
One way to create the weekly summary.
You do not have to name the ranges.

SumProduct 2022a.xlsm
ABCD
1DatesTSS
201-01-2158.3501-01-21338.69
302-01-2159.2208-01-21245
403-01-2191.2815-01-21325
503-01-212.9922-01-210
603-01-218.6329-01-21
704-01-218.6305-02-21
805-01-2126.6712-02-21
906-01-2141.2319-02-21
1007-01-2141.6926-02-21
1108-01-212005-03-21
1209-01-212512-03-21
1310-01-213019-03-21
1411-01-213526-03-21
1512-01-214002-04-21
1613-01-214509-04-21
1714-01-215016-04-21
1815-01-215523-04-21
1916-01-216030-04-21
2017-01-216507-05-21
2118-01-217014-05-21
2219-01-217521-05-21
2b
Cell Formulas
RangeFormula
D2:D5D2=SUMPRODUCT(TSS,--(Dates>=C2),--(Dates<C2+7))
Named Ranges
NameRefers ToCells
Dates='2b'!$A$2:$A$22D2:D5
TSS='2b'!$B$2:$B$22D2:D5
 
Upvote 0
One way to create the weekly summary.
You do not have to name the ranges.

SumProduct 2022a.xlsm
ABCD
1DatesTSS
201-01-2158.3501-01-21338.69
302-01-2159.2208-01-21245
403-01-2191.2815-01-21325
503-01-212.9922-01-210
603-01-218.6329-01-21
704-01-218.6305-02-21
805-01-2126.6712-02-21
906-01-2141.2319-02-21
1007-01-2141.6926-02-21
1108-01-212005-03-21
1209-01-212512-03-21
1310-01-213019-03-21
1411-01-213526-03-21
1512-01-214002-04-21
1613-01-214509-04-21
1714-01-215016-04-21
1815-01-215523-04-21
1916-01-216030-04-21
2017-01-216507-05-21
2118-01-217014-05-21
2219-01-217521-05-21
2b
Cell Formulas
RangeFormula
D2:D5D2=SUMPRODUCT(TSS,--(Dates>=C2),--(Dates<C2+7))
Named Ranges
NameRefers ToCells
Dates='2b'!$A$2:$A$22D2:D5
TSS='2b'!$B$2:$B$22D2:D5
Hi

Thank you for this. It points me in the right direction.

I have come across an anomaly in the way it handles the information. On 30/01/2021, there are 3 separate entries and I have entered it slightly different to yours to keep the dates shown as days but collating on the Sunday of each week.

Therefore D36 is wrong in my example because of the week containing 9 entries and not 7. I hadn't considered that.

1656837950723.png
 
Upvote 0
N.B. You can post an extract of your sheet with the forum's tool named XL2BB.
Does the following do what you require?

SumProduct 2022a.xlsm
ABCD
1DatesTSS
2Fri 1-Jan-2158.35  
3Sat 2-Jan-2159.22  
4Sun 3-Jan-2191.28  
5Sun 3-Jan-212.99  
6Sun 3-Jan-218.63220.47220.47
7Mon 4-Jan-218.63  
8Tue 5-Jan-2126.67  
9Wed 6-Jan-2141.23  
10Thu 7-Jan-2141.69  
11Fri 8-Jan-2120.00  
12Sat 9-Jan-2125.00  
13Sun 10-Jan-2130.00193.22193.22
14Mon 11-Jan-2135.00  
15Tue 12-Jan-2140.00  
16Wed 13-Jan-2145.00  
17Thu 14-Jan-2150.00  
18Fri 15-Jan-2155.00  
19Sat 16-Jan-2160.00  
20Sun 17-Jan-2165.00350.00350.00
21Mon 18-Jan-2170.00  
22Tue 19-Jan-2175.00  
2b
Cell Formulas
RangeFormula
C2:C22C2=IF(AND(WEEKDAY(A2,2)=7,A2<A3),SUMPRODUCT(TSS,--(Dates<=A2),--(Dates>A2-7)),"")
D2:D22D2=IF(AND(WEEKDAY(A2,2)=7,A2<A3),SUMIFS(B:B,A:A,"<="&A2,A:A,">="&A2-6),"")
Named Ranges
NameRefers ToCells
Dates='2b'!$A$2:$A$22C2:D22
TSS='2b'!$B$2:$B$22C2:D22
 
Upvote 0
That's fantastic. Thank you very much.

Just playing with converting it into a graph of some sort now. Cannot seem to get it into a vertical bar chart but I'll just keep playing. I am sure I will be able to work that out via trial and error.

The formula is total gobbledy-gook to me but what is the difference between your C2 and D2 formulas as they appear achieve the same result? Is it just another way of achieving what C2 does so that either could be used. I do not appear to need both.

Just wondering if there is an advantage to either formula maybe?

I saw this XL2BB add-on last night but haven't installed as yet.
 
Upvote 0
That's fantastic. Thank you very much.
Not sure if it is possible with your data, but if the final date entry is a Sunday I think that you will be missing the final result. See column D below using the column D formula from post #8.
Alternative approach suggested in column C

BTW, 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’)

22 07 03.xlsm
ABCD
1DatesTSS
2Fri, 1-Jan-2158.35  
3Sat, 2-Jan-2159.22  
4Sun, 3-Jan-2191.28  
5Sun, 3-Jan-212.99  
6Sun, 3-Jan-218.63220.47220.47
7Mon, 4-Jan-218.63  
8Tue, 5-Jan-2126.67  
9Wed, 6-Jan-2141.23  
10Thu, 7-Jan-2141.69  
11Fri, 8-Jan-2120.00  
12Sat, 9-Jan-2125.00  
13Sun, 10-Jan-2130.00193.22193.22
14Mon, 11-Jan-2135.00  
15Tue, 12-Jan-2140.00  
16Wed, 13-Jan-2145.00  
17Thu, 14-Jan-2150.00  
18Fri, 15-Jan-2155.00  
19Sat, 16-Jan-2160.00  
20Sun, 17-Jan-2165.00350.00 
21
22
Sum weeks
Cell Formulas
RangeFormula
C2:C20C2=IF(AND(WEEKDAY(A2,2)=7,OR(A2<A3,A3="")),SUM(B$2:B2)-SUM(C$1:C1),"")
D2:D20D2=IF(AND(WEEKDAY(A2,2)=7,A2<A3),SUMIFS(B:B,A:A,"<="&A2,A:A,">="&A2-6),"")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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