Count uniques per column value

anonemous

New Member
Joined
Dec 2, 2015
Messages
16
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
  2. MacOS
I have a large one year dataset (around 20,000 rows) where there are two main columns, one is the unique identifier (duplicated), the other is the employee assigned to that unique identifier (unique).

I am trying to develop a formula to count the number of unique employees assigned to each identifier, as an example below. Columns A-B is the data. Columns D-E is what I want the output to look like. So far I have tried some SUM and FREQUENCY, none that seem to work seamlessly or perhaps I am making the formula too complicated for what I need to do.

Thank you very much for your knowledge.


Excel 2013/2016
ABCDE
1ProjectEmployeeProjectEmployees
22017-00011411 - John2017-00011
32017-00021411 - John2017-00022
42017-0002212 - David2017-00031
52017-00031411 - John2017-00041
62017-00041411 - John2017-00051
72017-00051411 - John2017-00061
82017-00061411 - John2017-00071
92017-00071411 - John2017-00081
102017-00081411 - John2017-00093
112017-00091411 - John2017-00101
122017-0009212 - David2017-00111
132017-0009344 - Jason2017-00121
142017-00101411 - John2017-00131
152017-00111411 - John2017-00141
162017-00121411 - John2017-00152
172017-00131411 - John
182017-00141411 - John
192017-00151411 - John
202017-00153773 - Charles
Data Sheet
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
if i undertand correctly then, this should work in cell E2
=COUNTIF(A:A,D2)
fill down as needed

hth,
Ross
 
Last edited:
Upvote 0
Try:
Assumes there are no blank columns in the Employee field.
This is an array formula and must be entered with CTRL-SHIFT-ENTER.
Drag formula down rows as needed.
Excel Workbook
ABCDE
1ProjectEmployeeProjectEmployees
22017-00011411 - John2017-00011
32017-00021411 - John2017-00022
42017-0002212 - David2017-00031
52017-00031411 - John2017-00041
62017-00041411 - John2017-00051
72017-00051411 - John2017-00061
82017-00061411 - John2017-00071
92017-00071411 - John2017-00081
102017-00081411 - John2017-00093
112017-00091411 - John2017-00101
122017-0009212 - David2017-00111
132017-0009344 - Jason2017-00121
142017-00101411 - John2017-00131
152017-00111411 - John2017-00141
162017-00121411 - John2017-00152
172017-00131411 - John
182017-00141411 - John
192017-00151411 - John
202017-00153773 - Charles
Sheet
 
Upvote 0
In E2 control+shift+enter, not just enter, and copy down:

=SUM(IF(FREQUENCY(IF($A$2:$A$20=$D2,IF(1-($B$2:$B$20=""),MATCH($B$2:$B$20,$B$2:$B$20,0))),ROW($B$2:$B$20)-ROW($B$2)+1),1))
 
Upvote 0
@Aladin - in your formula is there an advantage to using 1-($B$2:$B$20="") vs $B$2:$B$20 < > ""
 
Upvote 0
Thank you, @rpaulson @AhoyNC @Aladin Akyurek
All three formulas worked in the data sheet - Over hindsight, I did not realize it was possible to do @rpaulson 's method without reading the field with employee names, but just count for duplicated entries. It can be made to work since since all row possibilities can be deduped to uniques (e.g. no two rows were the same).

@AhoyNC and @Aladin Akyurek methods read through all the data, looked at duplicates and generated the count of employees based on the actual sum of matches per each identifier. This process took some time for the machine to parse the formula (not quick with ~20K rows!)

I have learned new formulas from this topic and appreciate the insight it has given me. Thank you, kind benefactors.
 
Last edited:
Upvote 0
You're welcome the formulas that Aladin & I gave would take into account if an employee name was duplicated on a project. Aladin's also took into account if there was a blank cell.
 
Upvote 0
[...]
Over hindsight, I did not realize it was possible to do @rpaulson 's method without reading the field with employee names, but just count for duplicated entries. It can be made to work since since all row possibilities can be deduped to uniques (e.g. no two rows were the same).
[...]

If no employee is associated with a project more than once, the COUNTIF solution is good enough...
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,382
Members
448,889
Latest member
TS_711

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