Summing with Index/Match within conditional OR statement

brent78

New Member
Joined
Aug 18, 2006
Messages
16
Office Version
  1. 365
Platform
  1. Windows
My goal is to sum all conditions where the index/match results correspond to the "age" being <0 or >3. I am able to do the formula for just one element at a time however I can not figure out how to combine this as one formula. My end result is summing all values instead of just items <0 and >3. The desired outcome of the below data (J3) is to show year 2023 / Type A as 8, not 12. Type B should be 7 in (J4). Thanks in advance!

test.xlsx
BCDEFGHIJK
120232024202520232024
2TypeSubTypeQuantityAgeAgeAgeTypeSumType (<0 or >3)
3A14012A1212
4A22-101B1919
5A33456
6A43456
7B15567
8B28234
9B36123
Sheet1 (2)
Cell Formulas
RangeFormula
J3:K4J3=SUM(IF($I3=$B3:$B9,IF(OR(INDEX($E3:$G9,0,MATCH(J$1,$E$1:$G$1,0))>3,INDEX($E3:$G9,0,MATCH(J$1,$E$1:$G$1,0))<0),$D3:$D9)))
 

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.
Can you explain how you got your answer of 8 & 7 for 2023 as I make it 7 & 5
 
Upvote 0
Can you explain how you got your answer of 8 & 7 for 2023 as I make it 7 & 5
Sorry, I did not write out my sum column which is "Quantity". Desired result for Type B quantity is 5, not 7. Type A should add the quantities 2+3+3=8.
 
Upvote 0
Ok thanks for that.
What version of Excel are you using?
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I just figured this out without using an "OR" statement. I solved it by using two sets of sum(if(index/match) functions and adding them together.

test.xlsx
BCDEFGHIJK
120232024202520232024
2TypeSubTypeQuantityAgeAgeAgeTypeSumQuantity (Age<0 or Age >3)
3A14012A86
4A22-101B511
5A33456
6A43456
7B15567
8B28234
9B36153
Sheet1 (2)
Cell Formulas
RangeFormula
J3:K4J3=SUM(IF($I3=$B$3:$B$9,IF(INDEX($E$3:$G$9,0,MATCH(J$1,$E$1:$G$1,0))>3,$D$3:$D$9)))+SUM(IF($I3=$B$3:$B$9,IF(INDEX($E$3:$G$9,0,MATCH(J$1,$E$1:$G$1,0))<0,$D$3:$D$9)))
 
Upvote 0
Another option is
Fluff.xlsm
ABCDEFGHIJK
120232024202520232024
2TypeSubTypeQuantityAgeAgeAgeTypeSumType (<0 or >3)
3A14012A86
4A22-101B55
5A33456
6A43456
7B15567
8B28234
9B36123
10
View
Cell Formulas
RangeFormula
J3:K4J3=SUM(SUMIFS($D$3:$D$9,$B$3:$B$9,$I3,INDEX($E$3:$G$9,,MATCH(J$1,$E$1:$G$1,0)),{"<0",">3"}))
 
Upvote 0
Another option is
Fluff.xlsm
ABCDEFGHIJK
120232024202520232024
2TypeSubTypeQuantityAgeAgeAgeTypeSumType (<0 or >3)
3A14012A86
4A22-101B55
5A33456
6A43456
7B15567
8B28234
9B36123
10
View
Cell Formulas
RangeFormula
J3:K4J3=SUM(SUMIFS($D$3:$D$9,$B$3:$B$9,$I3,INDEX($E$3:$G$9,,MATCH(J$1,$E$1:$G$1,0)),{"<0",">3"}))

Thanks! I like that your solution is cleaner.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Hi, see the linked file for an another possible solution (without Index/Match/Or statements)...

The formula used in the table:
=SUM(($A$3:$A$9=$H3)*((D$3:D$9<0)+(D$3:D$9>3))*($C$3:$C$9))

Summing.xlsx

Summing.png
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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