简体   繁体   中英

Get number of unique values from a column with multiple criteria

I am working on an Excel problem. Here is my questions:

name department year
a      cs        5
b      cs        8
c      cs        2
d      cs        3
a      cs        1
b      cs        10
a      ma        7
f      ma        8
h      ma        2

The question is to get the number of unique name (only occur once) with department="cs" and year >2, in this case the result is 2 (ie,"a" and "d" only occur once).

I knew the formula below might do the trick, but did not know how to put the range filtered by department="cs" and year >2 into the below formula.

=SUM(IF(COUNTIF(range, range)=1,1,0))

Use SUMPRODUCT:

=SUMPRODUCT((COUNTIFS(A:A,A2:INDEX(A:A,MATCH("zzz",A:A)),B:B,"cs",C:C,">2")=1)*(B2:INDEX(B:B,MATCH("zzz",A:A))="cs")*(C2:INDEX(C:C,MATCH("zzz",A:A))>2))

![在此处输入图片描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM