Formula for multiple distinct values & numbers of those values?

ArPharazon

Board Regular
Joined
May 3, 2004
Messages
51
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
I may be explaining this badly, which is probably why I haven't been able to come up with anything on Google for this.

I run a report every day for my job that I'd like to use a formula on that shows each distinct text value from a column and then how many instances of each there are.

At least I hope it can be done with a formula :)

Below is a generic example. What I'd like to end up seeing is: Name1 | 10 / Name2 | 6 / Name3 | 4 and filter out #N/A if possible. The values in this column are all the result of a vlookup.

Excel Distinct Values 8-5-20.jpg
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Something like this could work:

Book2
ABCD
1DataNameCount
2Name1Name19
3Name2Name26
4#N/AName34
5Name1  
6Name2  
7#N/A  
8Name3  
9Name2  
10Name1  
11#N/A
12Name1
13Name2
14Name1
15#N/A
16Name2
17Name3
18Name1
19#N/A
20Name3
21Name1
22#N/A
23#N/A
24Name1
25Name1
26Name2
27Name3
28#N/A
29
30
Sheet7
Cell Formulas
RangeFormula
C2:C10C2=IFERROR(INDEX($A:$A,AGGREGATE(15,6,ROW($A$2:$A$30)/(COUNTIF($C$1:$C1,$A$2:$A$30)=0)/NOT(ISNA($A$2:$A$30))/($A$2:$A$30<>""),1)),"")
D2:D10D2=IF(C2="","",COUNTIF(A:A,C2))
A4,A28,A22:A23,A19,A15,A11,A7A4=NA()


You should update your member profile to show which version of Excel you're using. Newer versions have new functions that might make this easier.
 
Upvote 0
2007 on my personal machine and 2013 on my work laptop.
 
Upvote 0
The formulas in post #2 should work on your work laptop. IFERROR and AGGREGATE were introduced in Excel 2010. For your home pc, try:

Book1
ABCDE
1DataNameCountHow many unique names
2Name1Name193
3Name2Name26
4#N/AName34
5Name1  
6Name2  
7#N/A  
8Name3  
9Name2  
10Name1  
11#N/A
12Name1
13Name2
14Name1
15#N/A
16Name2
17Name3
18Name1
19#N/A
20Name3
21Name1
22#N/A
23#N/A
24Name1
25Name1
26Name2
27Name3
28#N/A
29
30
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=IF(ROWS($C$2:$C2)>$E$2,"",INDEX($A:$A,SMALL(IF(ISTEXT($A$2:$A$30),IF(MATCH($A$2:$A$30,$A$2:$A$30,0)=ROW($A$2:$A$30)-ROW($A$2)+1,ROW($A$2:$A$30))),ROWS($C$2:$C2))))
D2:D10D2=IF(C2="","",COUNTIF(A:A,C2))
E2E2=SUM(SIGN(FREQUENCY(IF(ISTEXT($A$2:$A$30),MATCH($A$2:$A$30,$A$2:$A$30,0)),ROW($A$2:$A$30)-ROW($A$2)+1)))
A4,A28,A22:A23,A19,A15,A11,A7A4=NA()
Press CTRL+SHIFT+ENTER to enter array formulas.


This should work for your work laptop too. In the latest Excel 365, there's a new function called UNIQUE that would make this even easier.
 
Upvote 0
I will try both in the morning. Thanks, and I'll let you know.
 
Upvote 0
I used your first set of formulas, in my case I located the results below everything else. I replaced ranges with what I think are the correct values, I'm dealing with Column K.

K412 contains the first actual name in Column K (all the way up in K3), L412 should be "2". I'm not sure how to get all names from Column K to display. If I drag K412, the same name gets repeated.

I'm sure it's something simple I'm missing.

Report 8-5-20 1a.jpg


Report 8-5-20 1b.jpg
 
Upvote 0
2007 on my personal machine and 2013 on my work laptop.
If you update your Account details (click your user name at the top right of the forum) then helpers will always know what Excel version(s) & platform(s) you are using instead of having to ask each time or you having to remember to include that detail. :) (Don’t forget to scroll down & ‘Save’)

1596707760510.png
 
Upvote 0
Here's the difference:

=IFERROR(INDEX($K:$K,AGGREGATE(15,6,ROW($K$2:$K$409)/(COUNTIF($K$411:$K411,$K$2:$K$409)=0)/NOT(ISNA($K$2:$K$409))/($K$2:$K$409<>""),1)),"")

The range in red should refer to the cell immediately above the cell the formula is placed in (K412).
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,004
Members
449,203
Latest member
Daymo66

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