Summing an array based on multiple criteria (one column, one row)

s0up2up

Board Regular
Joined
Jan 30, 2012
Messages
84
Hi guys,

I am trying to sum an array based on multiple criteria, one being found in a row and the other found in a column. I've created an example below;

Sum the following variables:
Location :: A
Year :: 31/03/2015
Output :: This should output anything within the appropriate year, that has an A location.

Location 31/03/201431/03/201531/03/201631/03/201731/03/2018
C 27 54 42 60 66
D 63 12 16 39 1
E 15 77 72 30 57
C 20 43 48 34 73
C 72 79 62 32 51
A 42 11 6 23 70
D 26 64 15 63 44
E 77 44 3 8 12
A 74 68 75 66 46
F 18 62 49 69 32
C 33 16 41 31 56
A 33 10 23 30 30
D 24 21 50 64 69
B 5 50 28 19 48
A 38 18 45 24 31
D 43 26 44 3 73
B 6 32 72 38 54
C 18 75 48 59 24
B 4 25 52 41 6
A 38 19 67 1 19
C 3 45 38 25 25
B 59 27 72 29 73

<tbody>
</tbody>

Sorry if the example is weird, just roll with it.

I've tried SUMIFS, SUM(INDEXMATCH)s, etc and I just can't get it to work, does any one have any ideas?

Only requirement is that it isn't VBA, it has to be done via formula.

Any questions throw them in the comments.

s0up2up
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Here's one option:

ABCDEFGHIJ
1Location31/03/201431/03/201531/03/201631/03/201731/03/2018LocationDateSum
2C2754426066A31/03/2015126
3D631216391
4E1577723057
5C2043483473
6C7279623251
7A421162370
8D2664156344
9E77443812
10A7468756646
11F1862496932
12C3316413156
13A3310233030
14D2421506469
15B550281948
16A3818452431
17D432644373
18B632723854
19C1875485924
20B42552416
21A381967119
22C345382525
23B5927722973

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet3

Worksheet Formulas
CellFormula
J2=SUMIF(A2:A23,H2,OFFSET(B2:B23,0,MATCH(I2,B1:F1,0)-1))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Thanks Erik W and Goalman14 both work equally well.

Erik:
It never occurred to me to use an Offset, as soon as I saw that thought it was an awesomely creative move.

Goalman:
I had never seen a Sumproduct formula before, and it's kinda poorly documented online, so thanks for demonstrating it to me.

Thanks again,
s0up2up
 
Last edited:
Upvote 0
Glad we could help. If you click Help in Excel and ask about SUMPRODUCT, you'll get a very basic explanation of what it does. Which doesn't show 1% of its power. It can do some amazing things, like Timmtamm's link shows, and others.

In this case, it's probably a better choice than my offering, since it doesn't use the volatile OFFSET function.

Good luck.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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