Count unique values multiple conditions

liybpg

New Member
Joined
Mar 17, 2015
Messages
16
I have a large dataset and I need to count the number of unique entries in one column, if it belongs to one group or another (it is indicated in another column, e.g. it may give group ID of 23 or 34 or 193 etc). Ideally, it would be a formula which I can use across many entries (need to do this 1000+ times)

Anyone has any thoughts?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Aladin,

Thanks for the suggestion, please find it below (sorry cant see how to attach files).

What I want to do is to show, for example, the number of unique values of Names that are in category 1. Please bear in mind that this is a vastly simplified version, so I can't sort or rearrange data, ideal solution would be a formula.

Thank you!

NameCategory
ABC1
ABC2
XYZ1
BNM2
ABC2
XYZ2
BNM1
ABC1
XYZ1
ABC1

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
Hi,

Try this ARRAY formula, see below for how to enter it. The group category is in D1 and the formula can be dragged.

=COUNT(1/FREQUENCY(IF(B$1:B$100=D1,MATCH(A$1:A$100,A$1:A$100,0)),ROW(A$1:A$100)-ROW(A$1)+1))

This is an array formula which must be entered by pressing CTRL+Shift+Enter
and not just Enter. If you do it correctly then Excel will put curly brackets
around the formula {}. You can't type these yourself. If you edit the formula
you must enter it again with CTRL+Shift+Enter.
 
Upvote 0
Mike, this is great, thank you for you help with that! Took me couple of hours to come up with nothing :)

Aladin thanks for your attention to this as well

Hi,

Try this ARRAY formula, see below for how to enter it. The group category is in D1 and the formula can be dragged.

=COUNT(1/FREQUENCY(IF(B$1:B$100=D1,MATCH(A$1:A$100,A$1:A$100,0)),ROW(A$1:A$100)-ROW(A$1)+1))

This is an array formula which must be entered by pressing CTRL+Shift+Enter
and not just Enter. If you do it correctly then Excel will put curly brackets
around the formula {}. You can't type these yourself. If you edit the formula
you must enter it again with CTRL+Shift+Enter.
 
Upvote 0
Yes, they are

Thanks.

Row\Col
A​
B​
C​
D​
E​
1​
NameCategory
2​
2​
ABC
1
#Category#Unique name count
3​
ABC
2
1​
3​
4​
XYZ
1
2​
3​
5​
BNM
2
6​
ABC
2
7​
XYZ
2
8​
BNM
1
9​
ABC
1
10​
XYZ
1
11​
ABC
1

D1, just enter:
Rich (BB code):

=SUM(IF(FREQUENCY(B2:B11,B2:B11),1))

D3, control+shift+enter (cse), not just enter, and copy down:
Rich (BB code):

=IF(ROWS($D$3:D3)<=$D$1,MIN(IF(ISNUMBER(MATCH($B$2:$B$11,$D$2:D2,0)),"",$B$2:$B$11)),"")

E3, cse and copy down:
Rich (BB code):

=SUM(IF(FREQUENCY(IF($A$2:$A$11<>"",IF($B$2:$B$11=$D3,
    MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0))),ROW($A$2:$A$11)-ROW($A$2)+1),1))

note. You might want to remove the "~"& and &"" bits if there are no special meaning chars like < aroun the names.
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

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