Sum Values by month from 1st day to last day of each month, and specific date range

Zakky

Board Regular
Joined
Mar 26, 2016
Messages
152
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a spreadsheet that shows a day's sales in each column across the top from 1st day of year to the last day (365 columns of data). I am trying to find a dynamic way to sum the values for each product by month. The total for each month should start from 1st day of month to last day of month. As a bonus, would it also be possible to show a solution that would take sales from a specific start and end date, so if i wanted to see what the sales value is from, say 15th Jan to 20 March for a product. Your help with this problem is greatly appreciated. Thank you.

Excel..PNG
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Cannot manipulate data in a picture. Please reload your data using XL2BB
 
Upvote 0
try wityh Sumproduct

**Note : I extended the number of columns to Column "NB" because you said the number of columns is 365

cell B3 and copy to other cells
Excel Formula:
=SUMPRODUCT((TEXT($B$2:$NB$2,"MMM YY")=TEXT(B$8,"MMM YY"))*($A$3:$A$5=$A9)*($B$3:$NB$5))

cell B15 and copy to other cells
Excel Formula:
=SUMPRODUCT(($B$2:$NB$2>$B$14)*($B$2:$NB$2<$C$14)*($A$3:$A$5=$A15)*($B$3:$NB$5))

1720664384842.png
 
Upvote 0
Cannot manipulate data in a picture. Please reload your data using XL2BB
alansidman, thank you for the prompt reply. I can't get the XL2BB to work. I've downloaded it but it's not appearing in add-in. Have a nice day.
 
Upvote 0
try wityh Sumproduct

**Note : I extended the number of columns to Column "NB" because you said the number of columns is 365

cell B3 and copy to other cells
Excel Formula:
=SUMPRODUCT((TEXT($B$2:$NB$2,"MMM YY")=TEXT(B$8,"MMM YY"))*($A$3:$A$5=$A9)*($B$3:$NB$5))

cell B15 and copy to other cells
Excel Formula:
=SUMPRODUCT(($B$2:$NB$2>$B$14)*($B$2:$NB$2<$C$14)*($A$3:$A$5=$A15)*($B$3:$NB$5))

View attachment 113926
SunnyAlv, Thank you for the prompt reply. Both of your solutions are magic, beautifully done. Have a nice day.
 
Upvote 0
Hi, here's another option you can try that will probably be more performant than the SUMPRODUCT() alternative.

Book1
ABCDEFGHIJKLMN
1
201/01/202302/01/202303/01/202301/02/202302/02/202303/02/202301/03/202302/03/202303/03/202301/04/202302/04/202303/04/202331/12/2023
3Product A100200505006575018464219311449
4Product B110220555507282555327979186322
5Product C121242616057990868952469974683
6
7
801/01/202301/02/202301/03/202301/04/202301/05/202301/06/202301/07/202301/08/202301/09/202301/10/202301/11/202301/12/2023
9Product A350131510664000000049
10Product B3851447166160000000022
11Product C4241592187212000000083
12
13
1415/01/202320/03/2023
15Product A1421
16Product B1613
17Product C1779
Sheet1
Cell Formulas
RangeFormula
B9:M11B9=SUMIFS(INDEX($B$3:$N$5,MATCH($A9,$A$3:$A$5,0),0),$B$2:$N$2,">="&B$8,$B$2:$N$2,"<"&EOMONTH(B$8,0)+1)
B15:B17B15=SUMIFS(INDEX($B$3:$N$5,MATCH($A15,$A$3:$A$5,0),0),$B$2:$N$2,">="&B$14,$B$2:$N$2,"<"&C$14+1)
 
Upvote 0
If you normalize your data in a range/table, then you can easily pivot your data to achieve the expected results. Your data should be in columns and not rows. Long and Skinny versus short and fat.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,180
Members
452,615
Latest member
bogeys2birdies

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