Sum from multiple columns with criteria

helpme10

New Member
Joined
Aug 11, 2017
Messages
7
Hey all,

I inherited a workbook that is a bit disorganized, but we must still use it for now for the customers' sake. Rather than unique rows for each data point, it collects data horizontally in three groups of columns (so one unique ID or "transaction" produces three data points). This makes a lookup-type sum quite lengthy, as in SUMIFS()+SUMIFS()+SUMIFS()...

Is there a more efficient way to find these values in multiple columns, with multiple criteria, and sum them? I have a workbook to share in order to illustrate the point, but it seems I can't attach files here. I'll try to simplify it here:

Data
ABCDEFGHIJ
IDGenus1Location1Ratio1Genus2Location2Ratio2Genus3Location3Ratio3
7877****Eurasia0.06PapioAsia0.06PapioAfrica0.09
7816CanisAntarctica0.59PapioS. America0.74PapioS. America0.41
6430FelisAntartica0.6PapioAsia0.37FelisEurope0.85
794CanisAsia0.73CanisN. America0.49CanisS. America0.86
9571CanisAsia0.99OrycteropusAfrica0.24PapioAsia0.31

<tbody>
</tbody>
Query
ABC
GenusLocationSum of %
FelisAntarctica0.6
CanisAsia1.72
PapioAsia0.74

<tbody>
</tbody>

The formula for 'Sum of %' is basically
Code:
=SUMIFS(Data!D:D,Data!B:B,A2,Data!C:C,B2)+SUMIFS(Data!G:G,Data!E:E,A2,Data!F:F,B2)+SUMIFS(Data!J:J,Data!H:H,A2,Data!I:I,B2)

I'm not great with OFFSET() or SUMPRODUCT() yet, but I feel the answer lies somewhere between the two.

Thanks!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Re: Simplification: Sum from multiple columns with criteria

Try:

=SUM(IF((Data!$B$2:$H$6=A2)*(Data!$C$2:$I$6=B2),Data!$D$2:$J$6))
with Control+Shift+Enter

note that the ranges are offset from each other.


Edit: I noticed that you are asking about efficiency. The formula I provided is shorter, and perhaps easier to understand, but I don't know if it is more efficient. It's guaranteed to look at many, many cells that we know won't be a match. That's one reason it needs the row references on the ranges instead of a whole column reference. If you're looking for "efficiency", or speed of execution, I think it's likely that your existing formula, long as it is, will calculate quicker. (SUMIFS can use whole column references without loss of efficiency.) You may want to run some tests to see which of the formulas, if either, slows it down more.

Good luck!
 
Last edited:
Upvote 0
Re: Simplification: Sum from multiple columns with criteria

Thanks for the formula Eric! But your hunch was correct, Excel ran out of resources while attempting to calculate an entire column of that array formula. For a single row it worked fine, but I'll need them for the entire column.
 
Upvote 0

Forum statistics

Threads
1,215,377
Messages
6,124,597
Members
449,174
Latest member
chandan4057

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