Search code examples
google-sheetsuniquegoogle-sheets-formulacountingcount-unique

How to use COUNTUNIQUEIFS in Goole sheets with an OR condition where a cell can meets two conditions


I'm trying to find the count of unique rows that meet multiple criteria in sheets. Data is like this:

ID |TYPE
1  |T1;T2;T3
2  |T1;T7
3  |T2;T3
4  |T6

I want a count of IDs where type is either T1 or T2. The right answer is 3 (ids 1,2 and 3 have either target type)

=countuniqueifs(A:A,B:B,{"*t1*","*t2*"}) 

gives me an answer of 2.

Any help greatly apprciated.


Solution

  • try:

    =COUNTUNIQUE(IFNA(FILTER(A2:A, REGEXMATCH(B2:B, "T1|T2"))))
    

    enter image description here


    to avoid T11 count in when the criterion is T1:

    0