简体   繁体   中英

Excel formula: count of unique cells in column, IF corresponding row is certain value

Currently I have a formula that just counts the unique values in a column:

=SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))

However, I'd only like to count them if a corresponding cell in the same row has a certain value. Is this possible without using VBA?

For example:

     A        B

     1       Old
     1       Old
     2       New
     2       New
     3       Old
     3       New
     4       New

I want to get the count of unique values of the A cells that correspond to the "New" value in the B col. So the unique occurrence count in A for "New" would be 3

Have been looking over excel references and not seeing how I would do this with ranges of data.

You can use this formula

=SUM(IF(FREQUENCY(IF(B2:B10="New",A2:A10),A2:A10),1))

confirmed with CTRL + SHIFT + ENTER

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