Multiple Criteria from Multiple Columns - Any Combination Match

TheMacroNoob

Board Regular
Joined
Aug 5, 2022
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hello excel experts,

I am trying to do something very frustrating. I have a table and I am trying to sum any combination of criteria in two columns in particular. A SUMIFS doesn't work for reasons I can't quite verbalize.
Is there a workaround with SUMPRODUCT or something similar to SUM based on this:

Book2
BCDEFGHIJKL
5
6Any combination of Divison AND Region. So A Egypt, A USA, B USA, B Egypt should sum.
7
8DivisionRegionMonthYearProfitDivisionAB
9AUSA12201650RegionUSAEgypt
10BCANADA12201650Month12
11CUSA12201650Year2016
12BUSA12201650
13CUSA12201650Total:50
14ACANADA12201650Intended:200
15AEGYPT12201650
16AEGPYT12201650
17
Sheet1
Cell Formulas
RangeFormula
J13J13=SUM(SUMIFS(G9:G16,C9:C16,J8:K8,D9:D16,J9:K9,E9:E16,J10,F9:F16,J11))
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello excel experts,

I am trying to do something very frustrating. I have a table and I am trying to sum any combination of criteria in two columns in particular. A SUMIFS doesn't work for reasons I can't quite verbalize.
Is there a workaround with SUMPRODUCT or something similar to SUM based on this:

Book2
BCDEFGHIJKL
5
6Any combination of Divison AND Region. So A Egypt, A USA, B USA, B Egypt should sum.
7
8DivisionRegionMonthYearProfitDivisionAB
9AUSA12201650RegionUSAEgypt
10BCANADA12201650Month12
11CUSA12201650Year2016
12BUSA12201650
13CUSA12201650Total:50
14ACANADA12201650Intended:200
15AEGYPT12201650
16AEGPYT12201650
17
Sheet1
Cell Formulas
RangeFormula
J13J13=SUM(SUMIFS(G9:G16,C9:C16,J8:K8,D9:D16,J9:K9,E9:E16,J10,F9:F16,J11))
Apparently the best way to solve a problem in Excel is to post it to a forum.... To then solve it yourself...

The solution was the following formula:
=SUMPRODUCT(--(ISNUMBER(XMATCH(C9:C16,J8:K8))),--(ISNUMBER(XMATCH(D9:D16,J9:K9))),--(ISNUMBER(XMATCH(E9:E16,J10))),--(ISNUMBER(XMATCH(F9:F16,J11))),G9:G16)

Wow. Carry on.
 
Upvote 0
The solution was the following formula:
=SUMPRODUCT(--(ISNUMBER(XMATCH(C9:C16,J8:K8))),--(ISNUMBER(XMATCH(D9:D16,J9:K9))),--(ISNUMBER(XMATCH(E9:E16,J10))),--(ISNUMBER(XMATCH(F9:F16,J11))),G9:G16)
Tricky checking your formula because it actually returns 150 for the sample data not 200. However, that is because of the assumed typo in D16 which is EGPYT not EGYPT ;)

A considerably shorter formula would be
=SUM(FILTER(G9:G16,ISNUMBER(MATCH(C9:C16,J8:K8,0)*MATCH(D9:D16,J9:K9,0))*(E9:E16=J10)*(F9:F16=J11),0))
 
Upvote 0
Solution
Tricky checking your formula because it actually returns 150 for the sample data not 200. However, that is because of the assumed typo in D16 which is EGPYT not EGYPT ;)

A considerably shorter formula would be
=SUM(FILTER(G9:G16,ISNUMBER(MATCH(C9:C16,J8:K8,0)*MATCH(D9:D16,J9:K9,0))*(E9:E16=J10)*(F9:F16=J11),0))
Ha, you got me! I didn't spot the typo until I started seriously working on the problem.

Your formula is much more readable and understandable... I think I overcomplicated this issue quite a bit.

I marked your answer as THE answer and I will make use of that logic for sure.

Thank you!
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,028
Members
449,092
Latest member
ikke

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