SUMIF criteria as array

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,910
Office Version
  1. 365
Platform
  1. Windows
Hi

Say I have the following formula:

=SUM(SUMIF(A2:A10,{"a","b"},B2:B10))

This will yield the result of all values in B2:B10 where the corresponding value in column A is either "a" or "b". No CSE required because of the inline array constant.

So lets say we place "a" and "b" in D1:D2 and use:

=SUM(SUMIF(A2:A10,D1:D2,B2:B10))

So say I do not commit with CSE. It will yield the result adjacent to "b", not "a". Why?

In other cases where an array is passed and not computed as an array Excel tends to yield the 1st array item. This picks up the last.

I realise this is academic but curious to know why??
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Jon.

a, b and a/b works correct.
Excel Workbook
ABCDEFGH
1999999
2a11b11a11
3a11b11b11
4a11b11a11
5a11b11b11
6a11b11a11
7a11b11b11
8a11b11a11
9a11b11b11
10a11b11a11
Sheet
 
Upvote 0
Jon,

Because you put the formula below (without CSE) in row 2.

=SUM(SUMIF(A2:A10,D1:D2,B2:B10))



If you put the formula in row 1 you would have got the sum corresponding to D1.

If you put the formula in row 3 you'll get 0 because there isn't a third item in the array.

So the position implies which value it calculates.
 
Upvote 0
I'm just going to reword my answer because it could be misconstrued.

Specifically, it is a "formula row" to "criteria range" intersection.

If your formula goes in row 3 then it will pick up the intersect of D1:D2 and 3:3 (which is nothing). If your formula goes in row 1 then it will pick up the intersect of D1:D2 and 1:1 (which is D1). etc...
 
Upvote 0

Forum statistics

Threads
1,223,786
Messages
6,174,551
Members
452,572
Latest member
KP53

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