Count of unique identifiers based on multiple criteria from different columns

sairb

New Member
Joined
Oct 20, 2018
Messages
3
I am trying to get a count of unique identifiers based on variables from two different columns. In addition, in one of those columns, I need to add multiple additional criteria. For example:

Column A Column B Column C
NJ Joe A
NJ John B
NY Mike A
CA Dave C
NJ Dan A
NJ Joe A
NJ Joe D
NY Pete A

What I am looking for is if Column A= ”NJ” or “NY” and Column C=A, then count unique names in Column B. In my example above, the total unique count would be 4 (Joe from NJ, Mike from NY, Dan from NJ and Pete from NY). The formula that I have been experimenting is this:
{=sum(--(frequency(if((C2:C8=”A”)*(A2:A8=”NJ”),B2:B8),B2:B8)>0))}
This formula would work if I only needed to incorporate one variable from column A, but I cannot seem to figure out how to add multiple criteria from column A.

Any help is greatly appreciated.
Thanks,
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
A
B
C
D
1
NJJoeA
4​
2
NJJohnB
3
NYMikeA
4
CADaveC
5
NJDanA
6
NJJoeA
7
NJJoeD
8
NYPeteA

<tbody>
</tbody>

D1=SUM(IF(FREQUENCY(IF(A1:A8<>A4,IF(C1:C8=C1,MATCH(B1:B8,B1:B8,0))),ROW(B1:B8)-ROW(B1)+1),1)) Control+Shift+Enter
 
Upvote 0
Thank you for the quick response Marziotullio. I see your formula is excluding A4 to bring in just NY and NJ. Suppose i have all 50 states and I just want to grab the ones I need. Is there a way to modify the formula after A1:A8 to extract just "NJ" and "NY" and all other states that i will eventually need? I want to be able to add up to 10 or so states that will be in the formula to calculate my unique name counts. My real life worksheet has codes and not states but for simplicity i used states in my example.
 
Upvote 0
Try

D1=SUM(IF(FREQUENCY(IF((A1:A8=A1)+(A1:A8=A3),IF(C1:C8=C1,MATCH(B1:B8,B1:B8,0))),ROW(B1:B8)-ROW(B1)+1),1)) control+shift+enter
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top