Combining multiple countifs

datadummy

Active Member
Joined
Mar 16, 2017
Messages
313
Office Version
  1. 365
Platform
  1. Windows
I am trying to combine multiple countifs and am not getting my desired amount. What I am trying to do is take multiple sets of criteria (departments) from the same column and then look at an additional column for a "YES" response and then divide all of those counts by a total count of all the specified departments. Here is an example of my current formula,

=COUNTIFS('Raw Data'!E:E,"FBC",'Raw Data'!G:G,"Yes")/COUNTIF('Raw Data'!E:E,"FBC")+COUNTIFS('Raw Data'!E:E,"Maternal Child",'Raw Data'!G:G,"Yes")/(COUNTIF('Raw Data'!E:E,"Maternal Child"))+COUNTIFS('Raw Data'!E:E,"NICU",'Raw Data'!G:G,"Yes")/COUNTIF('Raw Data'!E:E,"NICU")

Currently this is giving me 300% rather than 100%, I'm sure I have made an error somewhere in the process. I am open to another formula if there is a better one.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Maybe:

=SUM(COUNTIFS('Raw Data'!E:E,{"FBC","Maternal Child","NICU"},'Raw Data'!G:G,"Yes"))/SUM(COUNTIF('Raw Data'!E:E,{"FBC","Maternal Child","NICU"}))
 
Upvote 0
That did the trick, thank you!!

I have another dilemma that I'm trying to get to work, I am taking a similar methodology where I am looking at column E for my department, then looking at 2 separate columns (AO,AQ) for a "YES" response in either. Should this be an OR statement and how should I write the function?
 
Upvote 0
Well you could try something like:

=SUMPRODUCT(--(E:E="NICU"),SIGN((AO:AO="yes")+(AQ:AQ="yes")))

where NICU is the department. However, you may notice a bit of a lag with this formula. SUMPRODUCT is not as efficient with whole column references as COUNTIF is. It's best to use the bottom row like this:

=SUMPRODUCT(--(E1:E100="NICU"),SIGN((AO1:AO100="yes")+(AQ1:AQ100="yes")))


Note that the + is the equivalent of an OR.
 
Upvote 0
Here is what I entered and am getting an error...
=SUMPRODUCT('Raw Data'!(E2:E1158="NICU"),SIGN(('Raw Data'!AO2:AO1158="Yes")+('Raw Data'!AQ2:AQ1158="Yes")))

Any thoughts?
 
Upvote 0
Try;

Code:
=SUMPRODUCT(--('Raw Data'!E2:E1158="NICU"),SIGN(('Raw Data'!AO2:AO1158="Yes")+('Raw Data'!AQ2:AQ1158="Yes")))
 
Upvote 0
That worked so would there be a way to incorporate the step above where you included all the departments, FBC, Maternal Child, NICU?
 
Upvote 0
OK, getting a little complicated here :)

=SUMPRODUCT(--ISNUMBER(MATCH('Raw Data'!E2:E1158,{"FBC","Maternal Child","NICU"},0)),SIGN(('Raw Data'!AO2:AO1158="Yes")+('Raw Data'!AQ2:AQ1158="Yes")))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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