How to count with Multiple Criteria

GMC The Macro Man

Board Regular
Joined
Mar 23, 2023
Messages
104
Office Version
  1. 2021
Platform
  1. Windows
Hi everyone, I hope you are all good :)
I'm looking to see if someone can help me with the best way to count using multiple criteria

I have a large table of student grades that I need to summarize which are in the attached table "Nat_Grades".
In Column "J3", I want to be able to count the number of pupils in S4 who have scored a "NAT 3" across the four subjects in the range C2:F22, (The answer is "7"). I then want to count the total number of Nat 4, Nat 5, Nat 6 & Nat 7's for pupils in S4. I would do the same for S5 and then S6.
This data would be entered in to cells J3:N5.
The table is just a small excerpt as the original has 25 different subjects and over 400 students so it would be a big task to do manually :(
I've looked across many forums but just cannot seem to find the formula to count across different columns with multiple criteria so I hope someone on here may help

TIA
GMC

Book2
ABCDEFGHIJKLMN
1Pupil IDYearARTBiologyEnglishMaths
2A1S4Nat 3Nat 3Nat 4YearNat 3Nat 4Nat 5Nat 6Nat 7
3A2S4Nat 4Nat 3Nat 3Nat 4S4
4A3S4Nat 3Nat 4Nat 4Nat 4S5
5A4S4Nat 4Nat 4Nat 4Nat 4S6
6A5S4Nat 3Nat 4Nat 4
7A6S4Nat 3Nat 4Nat 4
8A7S4Nat 4Nat 4Nat 4
9A8S5Nat 5Nat 5Nat 5
10A9S5Nat 6Nat 6Nat 5Nat 6
11A10S5Nat 5Nat 5Nat 6
12A11S5Nat 5Nat 5Nat 6Nat 6
13A12S5Nat 5Nat 6Nat 5
14A13S5Nat 6Nat 6Nat 5
15A14S5Nat 6Nat 5Nat 6Nat 5
16A15S6Nat 7Nat 6Nat 6
17A16S6Nat 7Nat 7Nat 6
18A17S6Nat 7Nat 7Nat 7Nat 6
19A18S6Nat 7Nat 6Nat 7Nat 6
20A19S6Nat 6Nat 6Nat 7Nat 7
21A20S6Nat 6Nat 7
22A21S6Nat 5Nat 6Nat 7
Sheet1
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How about this:
Book1
ABCDEFGHIJKLMN
1Pupil IDYearARTBiologyEnglishMaths
2A1S4Nat 3Nat 3Nat 4YearNat 3Nat 4Nat 5Nat 6Nat 7
3A2S4Nat 4Nat 3Nat 3Nat 4S4717000
4A3S4Nat 3Nat 4Nat 4Nat 4S50013110
5A4S4Nat 4Nat 4Nat 4Nat 4S60011012
6A5S4Nat 3Nat 4Nat 4
7A6S4Nat 3Nat 4Nat 4
8A7S4Nat 4Nat 4Nat 4
9A8S5Nat 5Nat 5Nat 5
10A9S5Nat 6Nat 6Nat 5Nat 6
11A10S5Nat 5Nat 5Nat 6
12A11S5Nat 5Nat 5Nat 6Nat 6
13A12S5Nat 5Nat 6Nat 5
14A13S5Nat 6Nat 6Nat 5
15A14S5Nat 6Nat 5Nat 6Nat 5
16A15S6Nat 7Nat 6Nat 6
17A16S6Nat 7Nat 7Nat 6
18A17S6Nat 7Nat 7Nat 7Nat 6
19A18S6Nat 7Nat 6Nat 7Nat 6
20A19S6Nat 6Nat 6Nat 7Nat 7
21A20S6Nat 6Nat 7
22A21S6Nat 5Nat 6Nat 7
Sheet1
Cell Formulas
RangeFormula
J3:N5J3=SUMPRODUCT(($B$2:$B$22=$I3)*($C$2:$F$22=J$2))
 
Upvote 1
Solution
I think dreid1011 has answered the second part of your question.

I want to be able to count the number of pupils in S4 who have scored a "NAT 3" across the four subjects in the range C2:F22, (The answer is "7"). I then want to count the total number of Nat 4, Nat 5, Nat 6 & Nat 7's for pupils in S4.

He answered the part in blue. The answer to the green part is trickier. As far as I can tell, the answer to that is 0. There are no S4 pupils who have Nat 3 in all 4 subjects. There are 2 who have Nat 3 and Nat 4 mixed, and one with all Nat 4. The rest are missing at least one score. I came up with a formula that comes up with a count of students who scored at least Nat 3 in all 4 subjects. And Nat 4 or above in all four subjects, and so on. Let us know if this is what you're looking for, or if you want a variation, like at least 3 scores, or something like that.

Book2
ABCDEFGHIJKLMN
1Pupil IDYearARTBiologyEnglishMaths
2A1S4Nat 3Nat 3Nat 4YearNat 3Nat 4Nat 5Nat 6Nat 7
3A2S4Nat 4Nat 3Nat 3Nat 4S421000
4A3S4Nat 3Nat 4Nat 4Nat 4S500300
5A4S4Nat 4Nat 4Nat 4Nat 4S600030
6A5S4Nat 3Nat 4Nat 4
7A6S4Nat 3Nat 4Nat 4
8A7S4Nat 4Nat 4Nat 4
9A8S5Nat 5Nat 5Nat 5
10A9S5Nat 6Nat 6Nat 5Nat 6
11A10S5Nat 5Nat 5Nat 6
12A11S5Nat 5Nat 5Nat 6Nat 6
13A12S5Nat 5Nat 6Nat 5
14A13S5Nat 6Nat 6Nat 5
15A14S5Nat 6Nat 5Nat 6Nat 5
16A15S6Nat 7Nat 6Nat 6
17A16S6Nat 7Nat 7Nat 6
18A17S6Nat 7Nat 7Nat 7Nat 6
19A18S6Nat 7Nat 6Nat 7Nat 6
20A19S6Nat 6Nat 6Nat 7Nat 7
21A20S6Nat 6Nat 7
22A21S6Nat 5Nat 6Nat 7
23
Sheet6
Cell Formulas
RangeFormula
J3:M5J3=SUM(--(MMULT(--(RIGHT($C$2:$F$22,1)>=RIGHT(J$2,1))*($B$2:$B$22=$I3),{1;1;1;1})=4))-SUM(K3:$O3)
N3:N5N3=SUM(--(MMULT(--(RIGHT($C$2:$F$22,1)>=RIGHT(N$2,1))*($B$2:$B$22=$I3),{1;1;1;1})=4))-SUM($O3:O3)
 
Upvote 0
The result is the same without using the RIGHT function.

Excel Formula:
=SUM(--(MMULT(($C$2:$F$22>=J$2)*($B$2:$B$22=$I3),{1;1;1;1})=4))-SUM(K3:$O3)
 
Upvote 1
How about this:
Book1
ABCDEFGHIJKLMN
1Pupil IDYearARTBiologyEnglishMaths
2A1S4Nat 3Nat 3Nat 4YearNat 3Nat 4Nat 5Nat 6Nat 7
3A2S4Nat 4Nat 3Nat 3Nat 4S4717000
4A3S4Nat 3Nat 4Nat 4Nat 4S50013110
5A4S4Nat 4Nat 4Nat 4Nat 4S60011012
6A5S4Nat 3Nat 4Nat 4
7A6S4Nat 3Nat 4Nat 4
8A7S4Nat 4Nat 4Nat 4
9A8S5Nat 5Nat 5Nat 5
10A9S5Nat 6Nat 6Nat 5Nat 6
11A10S5Nat 5Nat 5Nat 6
12A11S5Nat 5Nat 5Nat 6Nat 6
13A12S5Nat 5Nat 6Nat 5
14A13S5Nat 6Nat 6Nat 5
15A14S5Nat 6Nat 5Nat 6Nat 5
16A15S6Nat 7Nat 6Nat 6
17A16S6Nat 7Nat 7Nat 6
18A17S6Nat 7Nat 7Nat 7Nat 6
19A18S6Nat 7Nat 6Nat 7Nat 6
20A19S6Nat 6Nat 6Nat 7Nat 7
21A20S6Nat 6Nat 7
22A21S6Nat 5Nat 6Nat 7
Sheet1
Cell Formulas
RangeFormula
J3:N5J3=SUMPRODUCT(($B$2:$B$22=$I3)*($C$2:$F$22=J$2))
Thank you dreid1011, this helped me get the results i was looking for
 
Upvote 0
The result is the same without using the RIGHT function.

Excel Formula:
=SUM(--(MMULT(($C$2:$F$22>=J$2)*($B$2:$B$22=$I3),{1;1;1;1})=4))-SUM(K3:$O3)
Thank you Phuoc for taking the time to look at my solution
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,152
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