SUMIFS with multiples conditions on rows and columns

rkaczano

Board Regular
Joined
Jul 24, 2013
Messages
141
Office Version
  1. 365
Platform
  1. Windows
I am trying to do a SUMIF on a data table and I need to use criteria for the row data in the first two columns but also criteria for the column header data. I cannot seem to get this to work.

Example: assume in the table I have years (2010 to 2015) and month values (Jan to Dec) in columns A and B. Then assume I have volume data for a variety of products in columns C to F. And the product names are in the column headers for columns C and F.

If I know in advance that column C has data for "product1" and I wanted volume from 2010 February I would do SUMIFS(C2:C72, A2:A72,"2010", F2:F73,"February").

But I don't know exactly which column has the data for product1 but I do know that it is between columns C and F.

I am trying to widen the "sum range" which is the first term in the SUMIFS as follows: SUMIFS(C2:F72, A2:A72,"2010", F2:F73,"February", A1:F1, "product1"). But this is returning an error. I am effectively trying to use a SUMIF with multiple conditions but two of the conditions pertain to rows and one of the conditions pertains to columns.

There must be a way to do this - like using Index/Match logic but to return an array of results within a SUMIF

Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
is this something that could work for you? If something is not set up correctly, then please use the xl2bb add in and give a small sample copy of your data.

Some Mr Excel Questions.xlsx
ABCDEFGHIJK
1Year:2010
2MonthOct
3ProductProd1
4
5Total:812
6
7YearMonthProd1Prod2Prod3YearsMonthsProduct
82010Oct4783164012010AprProd1
92010Oct3344074592011FebProd2
102010Nov3184224232012JanProd3
112011Jan426479339Jun
122011Feb337307458Mar
132011Feb363459457May
142012Mar304350476Nov
152012Apr420332499Oct
162012May391464325
172012Jun322490425
18
19
Sheet3
Cell Formulas
RangeFormula
D5D5=SUM((D1&D2=B8:B17&C8:C17)*CHOOSE(MATCH(D3,D7:F7,0),D8:D17,E8:E17,F8:F17))
Cells with Data Validation
CellAllowCriteria
D1List=Years
D2List=Months
D3List=Product
 
Upvote 0
Maybe use SUMPRODUCT
Book1
ABCDEF
1YearMonthProd4Prod2Prod1Prod3
22021Jan189729545747
32021Feb497191104321
42022Jan656178451129
52022Feb766246118793
6
7
8Year2022
9MonthFeb
10ProdProd1
11Volume118
Sheet4
Cell Formulas
RangeFormula
C11C11=SUMPRODUCT(($A$2:$A$5=C8)*--($B$2:$B$5=C9)*--($C$1:$F$1=$C$10)*($C$2:$F$5))
 
Upvote 0
Another option
Excel Formula:
=SUMIFS(INDEX(C2:C72,,MATCH("Product1",C1:F1,0)),A2:A72,2010,B2:B72,"Feb")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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