# Counting Unique values with multiple criteria

1. ## Counting Unique values with multiple criteria

Hi All,

I am trying to count unique values with multiple criteria.

I used below Formula but I am getting #Value

{=SUM(--(FREQUENCY(IF(AND(B18:B23=D17,A18:A23=C17),C18:C23),C18:C23)>0))}

the table I am using for this example similar to below, once it is working will apply it to a much bigger table

Date color value
1-Jun Red 11
1-Jun Red 22
1-Jun Red 11
1-Jun Blue 11
2-Jun Red 22
2-Jun Red 22
2-Jun Blue 22
2-Jun Blue 22

2. ## Re: Counting Unique values with multiple criteria

Use this array formula:

=SUM(IF(FREQUENCY(IF(\$A\$18:\$A\$25=C\$17,IF(\$B\$18:\$B\$25=\$D17,\$C\$18:\$C\$25)),IF(\$A\$18:\$A\$25=C\$17,IF(\$B\$18:\$B\$25=\$D17,\$C\$18:\$C\$25)))>0,1))

Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

Don't type the curly brackets yourself - it won't work...

It's always better to post a sample workbook, by the way - that way we can see other problems that are undtectable from an unformatted table.

3. ## Re: Counting Unique values with multiple criteria

=sum(--(frequency(if((b18:b25=d17)*(a18:a25=c17),c18:c25),c18:c25)>0))

4. ## Re: Counting Unique values with multiple criteria

On second thoughts... a more generic formula (works with text and numbers) is (array entered):

=SUM(IF((\$C\$17=\$A\$18:\$A\$25)*(\$B\$18:\$B\$25=\$D\$17), 1/COUNTIFS(\$A\$18:\$A\$25, \$C\$17, \$B\$18:\$B\$25, \$D\$17, \$C\$18:\$C\$25, \$C\$18:\$C\$25)), 0)

5. ## Re: Counting Unique values with multiple criteria

Thank you All, that was really helpful

6. ## Re: Counting Unique values with multiple criteria

You're welcome.

It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1