Countif with multiple criteria in one row

Fishstats

New Member
Joined
Nov 18, 2011
Messages
16
Excel 2007
ABCDEFGHIJL
M
1NameAlewife - Alosa pseudoharengusAmerican Eel - Anguliia rostrataBanded Darter - Etheostoma zonaleBanded Killifish - Fundulus diaphanusBigmouth Buffalo - Ictiobus cyprinellusBlack Bullhead - Ameriurus melasBlack Crappie - Pomoxis nigromaculatusBlackchin Shiner - Notropis heterodon
2exnaEndemismexnanananananana
3CypCentFamilyCentCyp
4LepoLepomis
5sitesite_datezonerepPLANKOMNIINVERTINVERTOMNIOMNIPISCPLANK
687/5/2012SAV31
0.45
.66666
0.33333
0.66666
.333333
0.33333333.25

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>

Excel 2007.

I need to calculate a percent of the number of fish species that eat "PLANK" "INVERT" or "PISC". so in line 8 there are 5 species that eat one of the options. So the percentage should be 62.5%. Once I have this value I need to convert it to a score so <60% is 0; 60-70% is 3; and >70% is 5. I can get it to score but I can't get the equation to actually count the number of species eating one of those options. The equation I am using is:

=IF((COUNTIFS(Data!$E6:$CX6,">0",Data!$E$5:$CX$5,{"INVERT","PISC","PLANK"})/COUNTIF(Data!$E6:$CX6,">0")>0.7),5,IF((COUNTIFS(Data!$E6:$CX6,">0",Data!$E$5:$CX$5,{"INVERT","PISC","PLANK"})/COUNTIF(Data!$E6:$CX6,">0")<0.6),0,3))

any help on why the countif function will not count all three options would be greatly appreciated.

Thanks in advance.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
With your posted data in A1:M6

This regular formula returns the count of Row_5 items that are one of: PLANK, INVERT, or PISC
Code:
P1: =SUMPRODUCT(COUNTIF(E5:M5,{"PLANK";"INVERT";"PISC"}))

This regular formula returns the percentage of non-blank cells in Row_5 for that count
Code:
Q1: =P1/COUNTA(E5:M5)*100

This regular formula assigns a category to that percentage
Code:
R1: =INDEX({0;3;5},MATCH(Q1,{0;60;70.000000001},1))

For your data, these are the results:
P1: 5
Q1: 62.5
R1: 3

Alternatively, you could create lookup lists for the formulas
T1: PLANK
T2: INVERT
T3: PISC

U1: 0
U2: 60
U3: 70.000000001

V1: 0
V2: 3
V3: 5

and the formulas would be:
Code:
P1: =SUMPRODUCT(COUNTIF(E5:M5,T1:T3))
Q1: =P1/COUNTA(E5:M5)*100
R1: =INDEX(V1:V3,MATCH(Q1,U1:U3,1))

with the same results.

Is that something you can work with?
 
Upvote 0
I was hoping to keep it simple and make it a one cell formula. If that's not possible then I will work with what you've shown me.

Thanks!
 
Upvote 0
Like this?:
Code:
=INDEX({0;3;5},MATCH(SUMPRODUCT(COUNTIF(E5:M5,{"PLANK";"INVERT";"PISC"}))/COUNTA(E5:M5)*100,{0;60;70.000000001},1))
 
Upvote 0
Thanks for the quick response. That doesn't seem to work because on occasion there are zeros in rows similar to 6. I probably should have used a better example. To clarify here is a sample that is more common in the data set.

Excel 2007
ABCDEFGHIJL
1NameAlewife - Alosa pseudoharengusAmerican Eel - Anguliia rostrataBanded Darter - Etheostoma zonaleBanded Killifish - Fundulus diaphanusBigmouth Buffalo - Ictiobus cyprinellusBlack Bullhead - Ameriurus melasBlack Crappie - Pomoxis nigromaculatus
2exnaEndemismexnananananana
3CypCentFamilyCent
4LepoLepomis
5sitesite_datezonerepPLANKOMNIINVERTINVERTOMNIOMNIPISC
7
106/30/2011SAV33.333333
0
3.33333333002.23

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>


If the equation works the percent should be 66.67% and the score should be 3. Sorry for not being as clear as I could have been.
 
Upvote 0
Ok...I'm happy to help, but I'm confused. "similar to 6"? There's no row_6 in your example.
Using your example, can you describe exactly what should be calculated and which items to include/exclude...and the results?
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,408
Members
449,448
Latest member
Andrew Slatter

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