SUMIF with INDEX MATCH - Only the first match being returned

danhenshy23

New Member
Joined
Oct 3, 2016
Messages
38
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I am having issues with only the first match being returned when using SUMIF combined with IDEX and MATCH.

Here is an example of the formula I am using.

=SUMIF($B$2:$J$2,INDEX($R$2:$R$10,MATCH(K$2,$S$2:$S$10,0)),$B3:$J3)

Example image included below.
For Fred I would want to get 2 for USA and 4 for France, but as the formula is limiting to the first match only I am getting 2 for USA and 1 for France

How do I get around this please?
 

Attachments

  • Example.png
    Example.png
    32.8 KB · Views: 17

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
For Fred/Germany (K2 I think) use:
Excel Formula:
=SUMPRODUCT(($B$1:$J$1=IF($S$1:$S$10=K$1,$R$1:$R$10,""))*$B2:$J2)

and copy right/down

1728047007307.png
 
Upvote 0
Here's another way...

K3, confirmed with CONTROL+SHIFT+ENTER, copied across and down:

Excel Formula:
=SUM(IF(ISNUMBER(MATCH($B$2:$J$2,IF($S$2:$S$10=K$2,$R$2:$R$10),0)),$B3:$J3))

Hope this helps!
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or 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’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or 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’)
Done
 
Upvote 0
Here's another way...

K3, confirmed with CONTROL+SHIFT+ENTER, copied across and down:

Excel Formula:
=SUM(IF(ISNUMBER(MATCH($B$2:$J$2,IF($S$2:$S$10=K$2,$R$2:$R$10),0)),$B3:$J3))

Hope this helps!
I found that with this the formula doesn't move along the table headers once the array was added. Before CTRL+SHIFT+ENTER the formula does move along with the table headings
 
Upvote 0
In this example I've entered the formula in K3, confirmed it with CTRL_SHIFT+ENTER, and then copied it across. (I didn't copy it down because I don't have the rest of the data.) Does this help?

danhenshy.xlsm
ABCDEFGHIJKLMNOPQRST
1
2MunichDortmundLondonManchesterLiverpoolNew YorkWashingtonNiceParisGermanyEnglandUSAFranceMunichGermany
30003322130624DortmundGermany
4LondonEngland
5ManchesterEngland
6LiverpoolEngland
7New York USA
8WashingtonUSA
9NiceFrance
10ParisFrance
11
12
Sheet1
Cell Formulas
RangeFormula
K3:N3K3=SUM(IF(ISNUMBER(MATCH($B$2:$J$2,IF($S$2:$S$10=K$2,$R$2:$R$10),0)),$B3:$J3))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
For Fred/Germany (K2 I think) use:
Excel Formula:
=SUMPRODUCT(($B$1:$J$1=IF($S$1:$S$10=K$1,$R$1:$R$10,""))*$B2:$J2)

and copy right/down

View attachment 117686
With this I get a #VALUE! error from row 85 onwards and it just so happens that the data table I reference in the $S$1:$S$10 and $R$1:$R$10 part of the formula runs until Row 84. Does the #VALUE! error have something to do with how I am referencing the data table?
 
Upvote 0
In this example I've entered the formula in K3, confirmed it with CTRL_SHIFT+ENTER, and then copied it across. (I didn't copy it down because I don't have the rest of the data.) Does this help?

danhenshy.xlsm
ABCDEFGHIJKLMNOPQRST
1
2MunichDortmundLondonManchesterLiverpoolNew YorkWashingtonNiceParisGermanyEnglandUSAFranceMunichGermany
30003322130624DortmundGermany
4LondonEngland
5ManchesterEngland
6LiverpoolEngland
7New York USA
8WashingtonUSA
9NiceFrance
10ParisFrance
11
12
Sheet1
Cell Formulas
RangeFormula
K3:N3K3=SUM(IF(ISNUMBER(MATCH($B$2:$J$2,IF($S$2:$S$10=K$2,$R$2:$R$10),0)),$B3:$J3))
Press CTRL+SHIFT+ENTER to enter array formulas.

So this is how I have transferred the formula into my actual spreadsheet


=SUM(IF(ISNUMBER(MATCH(Calculation[[#Headers],[Column1]:[Column82.]],IF(Table9[[Outcome-Reason]:[Outcome-Reason]]=Calculation[[#Headers],[Column85]],Table9[[Outcome]:[Outcome]]),0)),Calculation[@[Column1]:[Column84]]))

When dragging across, the formula is sticking to Column85 rather than referencing each of the different headers (86,87,88 etc etc). This only happens if the formula is entered as an Array. If I drag the formula without entering as an Array, the column headings change as expected.
 
Upvote 0

Forum statistics

Threads
1,223,706
Messages
6,173,998
Members
452,542
Latest member
Bricklin

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