how to count unique entries with multiple condition

M

Michael

A B
china P1
korea P2
japan P3
china P2
korea P2
japan P1
U.S P2
India P1
China P1
U.S P2

I'm working with about 8000 data, I try to used this formula
=SUM(IF(FREQUENCY(MATCH(A1:A10,A1:A10,0),MATCH(A1:A10,A1:A10,0))>0,1)) to
count the unique entries in column A, which result 5. (China,
japan,korea,india,U.S)

However, i want to count unique entries in, let say P1 only, which should be
3. How to use function to get this result?
 
B

Bob Phillips

=SUM(IF(FREQUENCY(IF((A1:A10<>"")*(B1:B10="P1"),MATCH(A1:A10,A1:A10,0)),ROW(
INDIRECT("1:"&ROWS(A1:A10))))>0,1))

as an array formula, commit with Ctrl-Shift-Enter
 
M

Michael

Thanks! It works!

Bob Phillips said:
=SUM(IF(FREQUENCY(IF((A1:A10<>"")*(B1:B10="P1"),MATCH(A1:A10,A1:A10,0)),ROW(
INDIRECT("1:"&ROWS(A1:A10))))>0,1))

as an array formula, commit with Ctrl-Shift-Enter
 
M

Michael

A B
china P1-C40907
korea P2
japan P3
china P2
korea P2
japan P1-C40609
U.S P2
India P1
China P1
U.S P2

If my data contains like "P1-C40XXX", and i want to include it in the
counting. How to achieve it? i've tried
=SUM(IF(FREQUENCY(IF((A1:A10<>"")*(B1:B10="P1")*(B1:B10="P1-C40???),MATCH(A1:A10,A1:A10,0)),ROW(INDIRECT("1:"&ROWS(A1:A10))))>0,1))

but it doesn't work. Bob, can you help me?
 
R

Ron Rosenfeld

If my data contains like "P1-C40XXX", and i want to include it in the
counting. How to achieve it?

Try the array formula:

=SUM(IF(FREQUENCY(IF((A1:A10<>"")*((B1:B10="P1")+
(LEFT(B1:B10,6)="P1-C40")),MATCH(A1:A10,A1:A10,0)),
ROW(INDIRECT("1:"&ROWS(A1:A10))))>0,1))


--ron
 
B

Bob Phillips

Michael,

I read this that you want to include anything starting with P1 in the P1
numbers, so a slight change to Ron's suggestion

=SUM(IF(FREQUENCY(IF((A1:A10<>"")*(LEFT(B1:B10,2)="P1"),MATCH(A1:A10,A1:A10,
0)),ROW(INDIRECT("1:"&ROWS(A1:A10))))>0,1))

still an array formula.
 
R

Ron Rosenfeld

Michael,

I read this that you want to include anything starting with P1 in the P1
numbers, so a slight change to Ron's suggestion

=SUM(IF(FREQUENCY(IF((A1:A10<>"")*(LEFT(B1:B10,2)="P1"),MATCH(A1:A10,A1:A10,
0)),ROW(INDIRECT("1:"&ROWS(A1:A10))))>0,1))

still an array formula.

I read it that way at first; then when I went back and looked at his attempt,
with the P1-C40???, I thought my initial interpretation was incorrect.

Now he has several options.

--ron
 

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