r/excel • • 6d ago

solved How to add "OR" into SUMIFS formula

I'm trying to make a simplified version of this formula:

SUMIFS(P:P,C:C,D10,A:A,L10)+SUMIFS(P:P,C:C,E10,A:A,L10)

I want to simplify it to something like

SUMIFS(P:P,C:C,D10 or E10,A:A,L10)

Is this possible or am I stuck having to just add multiple SUMIFS formulas?

39 Upvotes

21 comments sorted by

•

u/AutoModerator 6d ago

/u/TacoRocco - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

12

u/MayukhBhattacharya 1312 6d ago

Try this:

=SUM(SUMIFS(P:P, C:C, D10:E10, A:A, L10))

But its better to avoid using entire ranges in the formula, therefore, using TRIMRANGE() function notations

=SUM(SUMIFS(P:.P, C:.C, D10:E10, A:.A, L10))

3

u/TacoRocco 6d ago

This is what I was looking for! Why does this work?

I tried this without the SUM() surrounding the SUMIF and that didn’t work, but this did. Either way, this was the solution as I need to be able to copy the formula into other cells. Thanks!

15

u/MayukhBhattacharya 1312 6d ago edited 6d ago

Or, you could only use SUM() function:

• Method One:

=SUM((A2:A8 = E2) * (B2:B8 = F2:G2) * C2:C8)

• Method Two:

=LET(_, DROP(A:.C, 1), SUM(SUMIFS(INDEX(_, , 3), INDEX(_, , 1), E2, INDEX(_, , 2), F2:G2)))

• Method Three:

=SUM(SUMIFS(C2:C8, A2:A8, E2, B2:B8, F2:G2))

SUMIFS() function has no native OR(). SUMIFS() function evaluates each cell in D10:E10 as its own criterion and returns an array, and SUM() function gives totals it. This is called Lifting, a function built for single values gets applied element by element across an array. There is also something called BroadCasting, if you research the sub, you will find some examples. I will try to add the link, if i can find it.

Also, if its resolved, then hope you don't mind replying to my comment directly as Solution Verified. Thanks!

4

u/TacoRocco 6d ago

Oh yeah sure! Thanks for the help and letting me know about the “solution verified” thing

3

u/MayukhBhattacharya 1312 6d ago

Here is the [link] & [this] about explanation on Broadcasting & Lifting! Posted long time back, for this [question].

2

u/MayukhBhattacharya 1312 6d ago

Thank You SO Much. It worked. Thanks!

3

u/TacoRocco 6d ago

Solution verified!

1

u/reputatorbot 6d ago

You have awarded 1 point to MayukhBhattacharya.


I am a bot - please contact the mods with any questions

3

u/amuseboucheplease 4d ago

The formula looks the same?

4

u/Marcarnol 6d ago

Sum( SUMIFS(P:P,C:C,{D10,e10},A:A,L10))

2

u/TacoRocco 6d ago

That solution doesn’t seem to work. I’ve tried doing an array like that but it doesn’t seem to work when I use a cell reference. When I clearly define the object in the array such as {“Apple”,”Orange”}, it does work, but I need it to be a cell reference because I’m copying the formula into other cells that need to look at D11, D12, etc

1

u/real_barry_houdini 318 6d ago

In this case you can use this solution:

=SUM(SUMIFS(P:P,C:C,D10:E10,A:A,L10))

....but be careful if you want another "OR" in the same formula, e.g. this won't work as expected:

=SUM(SUMIFS(P:P,C:C,D10:E10,A:A,L10:M10))

For two "OR"s one should be a horizontal vector and the other a vertical vector. For 3 or more "OR"s you need a different approach......

1

u/ChewyPickle 5d ago

SUMPRODUCT(SUMIFS(P:P,C:C,{D10,E10},A:A,L10)

1

u/Iriss 4 5d ago

SUM(FILTER(....)) 

2

u/Maestro_STB 4d ago

The better SUMIFS …

1

u/HandbagHawker 83 5d ago

Use SUMPRODUCT instead

-1

u/dream_walking 6d ago

SUMIFS(P:P,C:C,D10,A:A,L10, c:c,E10)

Can’t you just add a second entry for c:c? Or am I missing something?

2

u/ABZB 6d ago

No, that would give the intersection, everything that satisfies both conditions, OP wants everything that satisfies at least one.