Count Unique Values

paulycr

New Member
Joined
Jul 9, 2018
Messages
2
Hello,

I have a spreadsheet where column A represents a person (1-242) and column B represent a choice that person made (1-5). Each person in column A gets to make 12 choices (i.e. there are 12*242=2904 rows). I would like a formula that counts the number of unique choices each person makes. In the example below the unique count for person 1 would be 4, the unique count for person 2 would be 3.... etc.

Thanks in advance for any assistance.

PersonChoice
11
11
12
12
12
13
13
13
13
14
14
14
21
21
21
22
22
22
22
23
23
23
23
23
31
31
32

<tbody>
</tbody>
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi and welcome to MrExcel,

try this:
Book1
ABCDE
1PersonChoicePerson# Choice
21114
31123
41232
512
612
713
813
913
1013
1114
1214
1314
1421
1521
1621
1722
1822
1922
2022
2123
2223
2323
2423
2523
2631
2731
2832
Sheet1
Cell Formulas
RangeFormula
E2{=SUM(IF(FREQUENCY(IF($A$2:$A$28=D2,$B$2:$B$28),IF($A$2:$A$28=D2,$B$2:$B$28))>0,1))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
@ jorismoerings

I believe one if clause should suffice, i.e.

=SUM(IF(FREQUENCY(IF($A$2:$A$28=D2,$B$2:$B$28),$B$2:$B$28),1))

Do we have any counterevidence?
 
Upvote 0
@Aladin Akyurek,

You're right, one IF clause within FREQUENCY is sufficient as well. Mine will limit the BINS_array while yours take the full range.
Do not exactly know what the impact of this (in calculating time) will be as the data range grows to number of records as mentioned.
 
Upvote 0
@Aladin Akyurek,

You're right, one IF clause within FREQUENCY is sufficient as well. Mine will limit the BINS_array while yours take the full range.
Do not exactly know what the impact of this (in calculating time) will be as the data range grows to number of records as mentioned.

FREQUENCY numeric to numeric is very fast, faster than filter(X) to X than filter(X) to filter(X)...
 
Upvote 0
Both methods worked perfectly, thanks to both of you for taking the time to help.

Regards,
Paul
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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