How do you count data that matches more than one condition?

R

ryesworld

Hi All:
I need a formula that will count the number of occurences that a column
contains either "text string A" or "text string B".
 
B

Biff

Hi!

Try one of these:

=COUNTIF(A1:A10,"textA")+COUNTIF(A1:A10,"textB")

=SUMPRODUCT(--(ISNUMBER(MATCH(A1:A10,{"textA","textB"},0))))

Biff
 
R

RagDyer

Another way:

=SUM(COUNTIF(A:A,{"aa","bb"}))
--
HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================
 
R

ryesworld

Hi RagDyer...

I'd like to use your formula, "=SUM(COUNTIF(Sheet1!E1:E20,{"aa","bb"}))",
with your other formula from my other posting,
"=SUMPRODUCT((Sheet1!A1:A20=C1)*(Sheet1!B1:B20=D1))". In other words,
Sheet1!B1:B20=D1 or D2. (D1 is "aa" and D2 is "bb"). A number count should
only be retuned if all data ranges are true. (ie: if a zero was retuned from
either formula, zero will be the answer)

I hope that makes sense....
 
R

RagDyer

Don't know if I quite follow you.

Is this what you're looking for:

=SUMPRODUCT((Sheet1!A1:A20=C1)*(Sheet1!B1:B20={"aa","bb"}))

OR, do you want to reference particular cells, instead of hard coding the
actual text:

=SUMPRODUCT((Sheet1!A1:A20=C1)*((Sheet1!B1:B20=D1)+(Sheet1!B1:B20=D2)))

--
HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================
 
J

Jarek Kujawa

another way:

=SUM(IF((NOT(ISBLANK(your_range)))*(your_range<1),1,))

CTRL+SHIFT+ENTER this formula as it is an array-formula, after having done
it correctly the formula will show with curly brackets
{=SUM(IF((NOT(ISBLANK(your_range)))*(your_range<1),1,))}

also pls replace ";" with "," in my previous formula to look like this:

=COUNTIF(your_range,"<"&1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top