Countifs(Range,Criteria,AND(OR(range2,criteria2,range3,criteria3))

john316swan

Board Regular
Joined
Oct 13, 2016
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
I am trying to insert an and/or argument into countifs but can't get it to work. I tried SUMPRODUCT(ISNUMBER(MATCH,RANGE,CRITERIA,0))*ISNUMBER(ETC))

Can't figure out how to do it. For example

[TABLE="width: 200"]
<tbody>[TR]
[TD]Student A[/TD]
[TD]GPA[/TD]
[TD]SAT[/TD]
[TD]ACT[/TD]
[/TR]
[TR]
[TD]Student B[/TD]
[TD]3.0[/TD]
[TD]900[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]Student C[/TD]
[TD]3.4[/TD]
[TD]1200[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Student D[/TD]
[TD]3.0[/TD]
[TD]1080[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]Student E[/TD]
[TD]2.9[/TD]
[TD]1300[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Student F[/TD]
[TD]2.0[/TD]
[TD][/TD]
[TD]16[/TD]
[/TR]
[TR]
[TD]Student G[/TD]
[TD]2.4[/TD]
[TD]950[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Student H[/TD]
[TD]4.0[/TD]
[TD][/TD]
[TD]34[/TD]
[/TR]
[TR]
[TD]Student I[/TD]
[TD]4.0[/TD]
[TD]1450[/TD]
[TD]35[/TD]
[/TR]
[TR]
[TD]Student J[/TD]
[TD]3.8[/TD]
[TD]1300[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I want to count all the students who have >= 3.0 GPA, AND (>=1060 SAT OR >=20 ACT).

Thank you for your help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi,

I assume you don't want a student counted Twice if he/she is >=1060 SAT, And, >=20 ACT

So you can do separate COUNTIFS like F2 formula, OR, SUMPRODUCT, like G2 formula:


Book1
ABCDEFG
1Student AGPASATACT
2Student B39002166
3Student C3.41200
4Student D3108025
5Student E2.91300
6Student F216
7Student G2.4950
8Student H434
9Student I4145035
10Student J3.81300
Sheet492
Cell Formulas
RangeFormula
F2=COUNTIFS(B2:B10,">=3",C2:C10,">=1060")+COUNTIFS(B2:B10,">=3",D2:D10,">=20")-COUNTIFS(B2:B10,">=3",C2:C10,">=1060",D2:D10,">=20")
G2=SUMPRODUCT((B2:B10>=3)*((C2:C10>=1060)+(D2:D10>=20)>0))
 
Upvote 0
With Sumproduct you can only put conditions and, you can not put or, This also applies with countif and sumif.
To work, both results must be added.

[TABLE="class: grid, width: 900"]
<tbody>[TR]
[TD]Cell[/TD]
[TD]Formula[/TD]
[/TR]
[TR]
[TD]F2[/TD]
[TD]=SUMPRODUCT((B2:B10>=3)*(C2:C10>=1060))+SUMPRODUCT((B2:B10>=3)*(C2:C10<1060)*(D2:D10>=20))[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 320"]
<colgroup><col width="80" span="4" style="width:60pt"> </colgroup><tbody>[TR]
[TD="width: 80"][/TD]
[TD="width: 80, align: center"]A[/TD]
[TD="width: 80, align: center"]B[/TD]
[TD="width: 80, align: center"]C[/TD]
[TD="width: 80, align: center"]D[/TD]
[/TR]
[TR]
[TD="width: 80"]1[/TD]
[TD="width: 80"]STUDENT[/TD]
[TD="width: 80"]GPA[/TD]
[TD="width: 80"]SAT[/TD]
[TD="width: 80"]ACT[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD="align: right"]3.0[/TD]
[TD="align: right"]900[/TD]
[TD="align: right"]21[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]B[/TD]
[TD="align: right"]3.4[/TD]
[TD="align: right"]1200[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]C[/TD]
[TD="align: right"]3.0[/TD]
[TD="align: right"]1080[/TD]
[TD="align: right"]25[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]D[/TD]
[TD="align: right"]2.9[/TD]
[TD="align: right"]1300[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]E[/TD]
[TD="align: right"]2.0[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]F[/TD]
[TD="align: right"]2.4[/TD]
[TD="align: right"]950[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]G[/TD]
[TD="align: right"]4.0[/TD]
[TD][/TD]
[TD="align: right"]34[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]H[/TD]
[TD="align: right"]4.0[/TD]
[TD="align: right"]1540[/TD]
[TD="align: right"]35[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]I[/TD]
[TD="align: right"]3.8[/TD]
[TD="align: right"]1300[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

With the first part of the formula, you get the quantity 4 (blue numbers)
SUMPRODUCT((B2:B10>=3)*(C2:C10>=1060))

With the second part of the formula, you get the quantity 2 (green numbers)
SUMPRODUCT((B2:B10>=3)*(C2:C10<1060)*(D2:D10>=20))

But in the second part you have to discard the first 4 numbers, that's why you add the condition:
C2:C10<1060



In total there are 6 students who meet the conditions.

Try and tell me.
 
Upvote 0
Solution
See my G2 formula in Post # 2, the + (plus sign) acts as an OR operator for SUMPRODUCT...
 
Last edited:
Upvote 0
See my G2 formula in Post # 2, the + (plus sign) acts as an OR operator for SUMPRODUCT...

That's right, while I was working to put the example you put the formula, I looked at your answer and I learned something new. Thank you ;)
 
Upvote 0
Thank you DanteAmor, it's always a learning process for me too, I learn something new here almost everyday...:beerchug:
 
Upvote 0

Forum statistics

Threads
1,222,903
Messages
6,168,939
Members
452,227
Latest member
sam1121

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