Search code examples
excelcountunique

Count unique distinct values if condition is true


I try to count the unique values in list but they have to fulfill the condition I have set.

{=SUM(IF($A$1:$A$25=$D$2; 1/COUNTIF($B$1:$B$25; $B$1:$B$25); 0))}

excel count unique values

There the first 25 rows of the data as example.

How to count unique distinct values if condition is true in Excel?


Solution

  • Just will posting the question, I found the answer:

    {=SUM(IF($D$1=$A$1:$D$25, 1/(COUNTIFS($A$1:$A$25; $D$2; $B$1:$E$25; $B$1:$B$25)); 0))}
    

    correct anwser