SUMIF problem

PaulS

Board Regular
Joined
Feb 26, 2006
Messages
66
I tried to get totals per months of a list of transactions:
Col B: date in yy-mm-dd (dates are not always in chronological order)
Col C: transaction decription (not needed)
Col D: amount
Cells I9 to I20 month in numbers 1 - 12
I would like to have the totals per month in cells J9 to J20
I have tried
in J9 (total for January):
=SUMIF(B$9:B$910;MONTH(B$9:B$910)=I9;D$9:D$910)
in J10 (February):
=SUMIF(B$9:B$910;MONTH(B$9:B$910)=I10;D$9:D$910)
The formula returns no error, however the result is always 0 (zero).
What is wrong in this formula?
Thanks for your help,
Paul
 
Hi Paul,

Pivot table approach is super easy. Step by step instructions for XL 2003:

  • Insert > Name > Define
  • In the Name field, type in PvtRange
  • In the Refers to: field, type in this formula and click add. (Change Sheet1 for the name of your sheet and if the sheet name has spaces then suround it with single quotes, eg 'My Sheet'!$D:$D).
Rich (BB code):
=Sheet1!$B$1:index(Sheet1!$D:$D,Sheet1!$AL$9)
  • Select the cell where you want the table to appear.
  • Data > PivotTable
  • Next >
  • In the Range: field, type in pvtRange
  • Finish
  • Left click on the Date field in the pivot field window and drag it onto the Row Fields section of the pivot table.
  • Right click on the Date row field > Group and Show Detail > Group > hold down the CTRL key and choose Months and Years. Click OK. [If your dates do not overlap years or if you want the same month to be totalled across different years then you can only choose Months here].
  • Left click on the Column field in the pivot field window and drag it onto the Data Items section of the pivot table.
You are done and your date should look like this:
Excel Workbook
BCDEIJKAL
1DateSome columnAmount
210-10-0843
310-11-0532
410-12-1783
510-05-2118
610-03-1251
710-06-0473
810-09-2485Last Row
910-06-0443Sum of Amount28
1010-09-1070YearsDateTotal
1110-05-21402010Jan147
1210-07-1636Feb45
1310-09-107Mar51
1410-09-2440Apr50
1510-08-2758May67
1610-09-2412Jun189
1710-05-219Jul36
1810-01-1561Aug209
1910-02-1226Sep214
2010-08-2734Oct128
2110-06-1873Nov32
2210-04-2350Dec138
2310-01-2986Grand Total1306
2410-08-2792
2510-12-1755
2610-02-1219
2710-10-2285
2810-08-2725
Sheet1
Excel 2003
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
In case you are interested, I think that the formula approach you were trying would look like this:
Excel Workbook
BDEIJ
1DateAmount
210-10-0843
310-11-0532
410-12-1783
510-05-2118
610-03-1251
710-06-0473
810-09-2485MonthTotal
910-06-04431147
1010-09-1070245
1110-05-2140351
1210-07-1636450
1310-09-107567
1410-09-24406189
1510-08-2758736
1610-09-24128209
1710-05-2199214
1810-01-156110128
1910-02-12261132
2010-08-273412138
2110-06-1873
2210-04-2350
2310-01-2986
2410-08-2792
2510-12-1755
2610-02-1219
2710-10-2285
2810-08-2725
Sheet3
Excel 2003
Cell Formulas
RangeFormula
J9=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I9),$D$2:INDEX($D:$D,$AL$9))
J10=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I10),$D$2:INDEX($D:$D,$AL$9))
J11=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I11),$D$2:INDEX($D:$D,$AL$9))
J12=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I12),$D$2:INDEX($D:$D,$AL$9))
J13=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I13),$D$2:INDEX($D:$D,$AL$9))
J14=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I14),$D$2:INDEX($D:$D,$AL$9))
J15=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I15),$D$2:INDEX($D:$D,$AL$9))
J16=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I16),$D$2:INDEX($D:$D,$AL$9))
J17=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I17),$D$2:INDEX($D:$D,$AL$9))
J18=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I18),$D$2:INDEX($D:$D,$AL$9))
J19=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I19),$D$2:INDEX($D:$D,$AL$9))
J20=SUMPRODUCT(--(MONTH($B$2:INDEX($B:$B,$AL$9))=I20),$D$2:INDEX($D:$D,$AL$9))
 
Upvote 0
Thank you for your effort.
I used your SUMPRODUCT formula and I get a formula error at the second $B in the first INDEX function. Then I changed my formula - added the $-signs in the 'SUM(IF....'. Surprise: error on the same spot. Is it possible that the array formula does not work in this way?
I think I have to try your pivot table suggestion.
In my worksheet more than columns to be totaled.
It is like this - see your pivot table under 'sheet3'
- The monthly totals start in row 30 (row 28 is last - '28' is in cell AL10)
- Col E has a productcode - that decides in which column the amount of col D is also placed in one of col M to V.
- a pivot table as described above must give totals per month in each col starting in row 30.
So instead of using the amounts in col D, I can use the amounts in columns M to V.
The totals of the pivot tables must equal the totals in the worksheet.
This will give an overview of the costs per product per month.
Now I have to start my study of 'Pivot tables'!
Paul
 
Upvote 0
Colin, is it possible that there is a "problem" in the INDEX function in my version of Excel?
After entering the formula in the Name field as described by you I get an error on the second argument of the INDEX function. This happens on the same spot as I got in the 'SUM(IF...' and 'SUMPRODUCT(....' formulas. That cannot be a coincidence!
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,109
Members
452,302
Latest member
TaMere

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