Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count Unique values with a condition

Tags:

In column A I have list of different names. In column B, I have values either 0 or 1.

I want to get a count of all the unique names from column A which have 1 in column B.

Using below array formula I am able count unique names but not able to apply condition on column B.

=SUM(1/COUNTIF(A:A,A:A)) 
like image 533
Tejas Avatar asked Apr 11 '13 08:04

Tejas


People also ask

How do you use unique and Countif together?

Using SUM, IF, and COUNTIF Functions. In Excel, functions are always available to solve any operations. In this case, you can use a combination of SUM, IF and COUNTIF functions to count unique values in Excel. To count unique values, enter the formula =SUM(IF(COUNTIF(range, range)=1,1,0)) in the desired cell.


1 Answers

Assuming no more than 100 rows try this "array formula" to count the different names in A2:A100 where there is a 1 in the same row in B2:B100:

=SUM(IF(FREQUENCY(IF(B2:B100=1,IF(A2:A100<>"",MATCH(A2:A100,A2:A100,0))),ROW(A2:A100)-ROW(A2)+1),1))

confirmed with CTRL+SHIFT+ENTER

Note that I say different not unique as the two are not the same

like image 149
barry houdini Avatar answered Dec 13 '22 12:12

barry houdini