SUM COUNTIFS with AND + OR

GMC The Macro Man

Board Regular
Joined
Mar 23, 2023
Messages
104
Office Version
  1. 2021
Platform
  1. Windows
Hi there, I'm hoping someone can help me with this formula where I'm think I need to use TWO "OR" functions in the criteria
In the attached sheet, I need to count the number of pupils as follows
CELL I2 - SUM/Count the number of pupils in YEAR S4, who are in BAND 1 or 2 and have scored an A
CELL I3 - SUM/Count the number of pupils in YEAR S4, who are in BAND 3 to 10 and have scored an A
I used these formulas to get this
=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"1","2"}))
=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))

For the rest of this range, I2 to K7, the formula will be similar as above but change the YEAR group to S5 or S6 and the Maths to B or C.
Column "L" is where I have my challenge as this requires TWO "OR" functions (unless you guys can find an easier way).
For column L I need to SUM/Countifs the number of pupils, who are in BAND 1 or 2, (and here is the 2nd "OR") and have scored a D or E.

I cannot seem to get this to work. I've tried using AND but i'm not putting it correctly in the formula.

Could someone please help
Thanks
GMC

Book1
ABCDEFGHIJKLMNOP
1Pupil IDPupil NameYearBandMathsYearBandABCD or E
2A1AliceP11AS41~2011
3A2AlexS42B3~10000
4A3AndrewS41CS51~2001
5A4BobbyS43D3~10221
6A5BrianS42ES61~2010
7A6BettyS44E3~10111
8A7CharlesS41D
9A8ColinS57C
10A9DerekS56B=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"1","2"}))
11A10DianeS55A=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
12A11EdwardS54A
13A12EstherS57B
14A13FrankS51C
15A14FionaS52D
16A15GeorgeS66E
17A16GemmaS68E
18A17HarryS69D
19A18HelenS610C
20A19JohnS61B
21A20JennyS63A
22A21KevinS65B
23
24
Sheet1
Cell Formulas
RangeFormula
I2I2=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"1","2"}))
J2J2=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"B",Nat_Grade[Band],{"1","2"}))
K2K2=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"C",Nat_Grade[Band],{"1","2"}))
I3I3=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"A",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
J3J3=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"B",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
K3K3=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],"C",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
I4I4=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"A",Nat_Grade[Band],{"1","2"}))
J4J4=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"B",Nat_Grade[Band],{"1","2"}))
K4K4=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"C",Nat_Grade[Band],{"1","2"}))
I5I5=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"A",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
J5J5=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"B",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
K5K5=SUM(COUNTIFS(Nat_Grade[Year],$G$4,Nat_Grade[Maths],"C",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
I6I6=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"A",Nat_Grade[Band],{"1","2"}))
J6J6=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"B",Nat_Grade[Band],{"1","2"}))
K6K6=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"C",Nat_Grade[Band],{"1","2"}))
I7I7=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"A",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
J7J7=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"B",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
K7K7=SUM(COUNTIFS(Nat_Grade[Year],$G$6,Nat_Grade[Maths],"C",Nat_Grade[Band],{"3","4","5","6","7","8","9","10"}))
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How about
Excel Formula:
=SUM(COUNTIFS(Nat_Grade[Year],$G$2,Nat_Grade[Maths],{"D";"E"},Nat_Grade[Band],{"1","2"}))
 
Upvote 1
Solution
So its a Semi Colon instead of the comma which I was trying. 😠

As always Fluff...Many Thanks 😊😊😊
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

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