Excel Formula - SUMIFS with multiple criteria in one column of an excel table

RCBricker

Well-known Member
Joined
Feb 4, 2003
Messages
1,560
Good morning.

I am having trouble finding a solution. I need to sum the sumifs of some data that is in a table. I don't want to convert it to a range. there is only one criteria per column except the last column. There I have multiple criteria to sum together. I usually would use something like:

Code:
=sum(sumifs(sum_range,Criteria1_range,criteria1,criteria2_range,{criteria2_A, criteria2_B}))
[\code]

this results in a warning that excel has found a problem with my formula.  

For now I am using the work around of:

[code]
=sum(sumifs(sum_range,Criteria1_range,criteria1,criteria2_range,criteria2_A)+sumifs(sum_range,Criteria1_range,criteria1,criteria2_range,criteria2_B)))
[\code]

this works fine, however, I will be needing a sumifs with about 10 criteria in one column.  So the work around gets a bit inefficient.

any help would be greatly appreciated.

thanks,
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi

What are criteria2_A and criteria2_B?

Remark:in the second case (the workaround) do you need the sum()?
 
Upvote 0
Hi

What are criteria2_A and criteria2_B?

Remark:in the second case (the workaround) do you need the sum()?

don't know if you need the sum. I haven't tried to just add them without it.

As for what are the two criteria, they are the criteria that I need to add together to complete the sumifs I am trying to do.

if I wanted to sum all the sales for automobiles at my dealership, then I could just sum the amount column. Or I could sum certain types of cars like Honda. Or I could sum just Honda trucks. All of these work fine with a table. However, if I wanted to just sum white Honda trucks and black Honda trucks. That creates the result I am getting. Normally I would write it

Code:
=sum(sumifs("sales",model,honda,color,{"black", "White"}))

This would work on a range of data where I want to sum all the sales for all black and white Hondas. It doesn't work on a table of data. I am sure there is a way to write this for a table and as such I am seeking advice or guidance.

Thanks,
 
Upvote 0
Code:
=sum(sumifs(sum_range,Criteria1_range,criteria1,criteria2_range,{criteria2_A[COLOR=#ff0000][B],[/B][/COLOR] criteria2_B}))
[\code]

this results in a warning that excel has found a problem with my formula. [/QUOTE]

Perhaps you are not using a version of Excel (e.g. English language) for which the comma is the separator for horizontal arrays?

If so, either use the appropriate syntax for your version, or else use a semicolon, which, as far as I know, is universally used as the separator for vertical arrays.

Regards
 
Upvote 0
Hi

As for what are the two criteria, they are the criteria that I need to add together to complete the sumifs I am trying to do.

That is what criteria are for.

What I meant is what are criteria2_A and criteria2_B?
are they constants like "black", "white"?
are they references to cells like A3,D4?
are they named ranges that reference cells?
are they named constants?

=sum(sumifs("sales",model,honda,color,{"black", "White"}))

The formula you posted with "black" and "white" works also with values in tables unless you have some syntax error.
Examples of errors:
- in your regional settings the comma is not an array separator
- honda is a horizontal array with more than 2 values
- the criteria values are not constants

Please clarify with a small formula with only constants and references to ranges that does not work.
 
Upvote 0
Examples of errors:
- honda is a horizontal array with more than 2 values

Hi PGC,

Actually that syntax would be valid, in the sense that it would not error. In fact, the smaller of the two horizontal arrays would be extended such that its dimensions matched those of the larger, the additional entries in which all being assigned the error value #N/A.

For example, if honda was defined as J1:M1, i.e. a 4-cell horizontal range, then Excel would automatically redimension the color array

{"black","White"}

to

{"black","White","#N/A","#N/A")

i.e. also a 4-cell horizontal range.

In fact, if the color range included #N/A errors, these would be validly considered for summation as part of such a construction, i.e. for rows where the model is equal to either of the values in L1 and M1 and the color is #N/A.

Unthinkable in practice, of course, though interesting from a theoretical point of view!

Cheers
 
Upvote 0
Hi PGC,

Actually that syntax would be valid, in the sense that it would not error. In fact, the smaller of the two horizontal arrays would be extended such that its dimensions matched those of the larger, the additional entries in which all being assigned the error value #N/A.

For example, if honda was defined as J1:M1, i.e. a 4-cell horizontal range, then Excel would automatically redimension the color array

{"black","White"}

to

{"black","White","#N/A","#N/A")

i.e. also a 4-cell horizontal range.

In fact, if the color range included #N/A errors, these would be validly considered for summation as part of such a construction, i.e. for rows where the model is equal to either of the values in L1 and M1 and the color is #N/A.

Unthinkable in practice, of course, though interesting from a theoretical point of view!

Cheers

hmmm looks like this might turn into an interesting conversation.

As for the formula. Apparently, the error was mine. I also must have continued to write the same error yesterday afternoon. The formulas work fine now.
 
Upvote 0
Actually that syntax would be valid, in the sense that it would not error.

You are right, this would not be a syntax error, it would probably be a misunderstanding of how the function works.
We see it a lot with 2 OR criteria, in which the arrays must be orthogonal.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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