New Contributor

# Count unique values in range

Hi
I want to work out how many unique ingredients are in the Vegan restaurant, which are not in the Main Restaurant.
For instance here in recipe 1 - there is 1 unique ingredient (tofu - as 'avocado' was already used in recipe 1 in the Main Restaurant).
The issue with my formula now (see cell 'Count Unique Formula') is that avocado isn't being counted when it is compared to Main Restaurant in Recipe 1 range, but it is still being counted when compared to the Recipe 2.

4 Replies

# Re: Count unique values in range

``=SUMPRODUCT((C\$2:C\$4<>"")*ISERROR(MATCH(C\$2:C\$4,C\$5:C\$7,0)))``

in C10. Fill to the right to D10.

# Re: Count unique values in range

@arianegr  I have a coupe of questions.

Why can't you use the list you have in column B?

Are you interested in the TOTAL across all recipes or the # unique ingredients in each recipe?

If you are interested in individual recipes is it if the vegan recipe has a unique ingredient compared to the comparable regular recipe or across all other recipes?

Here is equation for each individual recipe vs whole regular menu:

``=SUMPRODUCT(--((COUNTIFS(\$C\$5:\$D\$7,C\$2:C\$4)+ISBLANK(C\$2:C\$4))=0))``

and here is whole vegan menu vs whole regular menu (again without using Col B)

``=SUMPRODUCT(((COUNTIFS(C5:E7,C2:E4)+ISBLANK(C2:E4))=0)/(COUNTIFS(C2:E4,C2:E4)+ISBLANK(C2:E4)))``

# Re: Count unique values in range

Hi @mtarler ,

Thank you very much for your input.

I used the first equation. When testing it by adding a third recipe - I found that it seems to double count tofu.

For clarification, I want to count the incremental unique amount of vegan ingredients which are NOT used in the main restaurant.

In the file attached, seems like it double counts tofu if it's being used in another vegan recipe - see file attached.

I think we are nearly there!

# Re: Count unique values in range

@arianegr  Ah, you want it to be incremental, that is the part I didn't get.  That said you needed to make a variation of the second formula that was for the total.  I bet there is an 'easier' version but this is what I came up with:

``=SUMPRODUCT(((COUNTIFS(\$C\$6:\$E\$8,\$C\$2:C5)+ISBLANK(\$C\$2:C5))=0)/(COUNTIFS(\$C\$2:C5,\$C\$2:C5)+ISBLANK(\$C\$2:C5)))``