Counting Unique "Items"

gdseric

New Member
Joined
Sep 17, 2002
Messages
2
Need help! I have struggled with this for two days! I know it's right in front of me, but...

If I wanted to count the unique occurrences of items in a range (in Excel, obviously), how do I do it? For example, I have 516 rows of data in a worksheet (all participant/student activity related)...approximately 120 different students comprising 516 different activities. I can count the number of activities, no sweat, and can even categorize them by activity code, but how do I count the number of unique participants (with unique social security numbers) in the worksheet? 516 social security numbers in a list, but only about 120 students.

I am trying hard not to breach confidentiality, hence the vague question!

Thanks in advance...
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
On 2002-09-18 11:35, gdseric wrote:
Need help! I have struggled with this for two days! I know it's right in front of me, but...

If I wanted to count the unique occurrences of items in a range (in Excel, obviously), how do I do it? For example, I have 516 rows of data in a worksheet (all participant/student activity related)...approximately 120 different students comprising 516 different activities. I can count the number of activities, no sweat, and can even categorize them by activity code, but how do I count the number of unique participants (with unique social security numbers) in the worksheet? 516 social security numbers in a list, but only about 120 students.

I am trying hard not to breach confidentiality, hence the vague question!

Thanks in advance...

Let A2:A520 house the SSNs.

Use one of:

=SUM(IF(LEN(A2:A520),1/COUNTIF(A2:A520,A2:A520)))

which you need to array enter using control+shift+enter (not just enter).

=COUNTDIFF(A2:A520)

which you enter normally.

COUNTDIFF is part of morefunc.xll, an add-in that you can download from:

http://longre.free.fr/english/index.html
 

gdseric

New Member
Joined
Sep 17, 2002
Messages
2
That did it, Aladin! I knew it was something simple. Thanks for the referral on the add-in. Didn't have that one! Eric
 

Mark W.

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,654

ADVERTISEMENT

Here's how it's done using a PivotTable...
Book3
ABCDEFGHI
1StudentActivityUniqueSumofUniqueTotal
2641-43-7466LMN0.333333Total5
3148-06-7463LMN0.333333
4641-43-7466XYZ0.333333
5531-32-6817XYZ0.5
6760-75-1566ABC0.5
7760-75-1566DEF0.5
8641-43-7466ABC0.333333
9547-55-7058LMN0.333333
10547-55-7058XYZ0.333333
11148-06-7463ABC0.333333
12531-32-6817ABC0.5
13148-06-7463DEF0.333333
14547-55-7058ABC0.333333
15
16
Sheet1
 

Chris Davison

MrExcel MVP
Joined
Feb 15, 2002
Messages
1,790
Aladin,

is the LEN thrown in to prevent any DIV/0 error if there's a blank in the range ?

ta
Chris
 

Forum statistics

Threads
1,144,292
Messages
5,723,537
Members
422,502
Latest member
barakgahtan

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
Top