List the Common Values in A Column

austinandreikurt

Board Regular
Joined
Aug 25, 2020
Messages
91
Office Version
  1. 2016
Platform
  1. Windows
Hi, I have a list of values, might be numbers or text or group of words, but they will be just considered as value in a cell individually from A2:A300. I want to list the top 5 of the most commonly used values from the list and put them in Cell B1 only. Please make the formula easy to edit if incase I will need the top 4 only. But max will be top 5. Thank you!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
something like this with defined Top number

TopTopList
5Top5811 | 5028 | 6772 | aaa9 | aaa8

TopTopList
4Top5028 | 5811 | 6772 | aaa9


post representative example with XL2BB or link to the shared excel file via dropbox, googledrive, onedrive or any similar service
 
Last edited:
Upvote 0
What do you want to happen if there are ties in 5th place?
Example below. Clearly you would want b, c, 2 and 3 returned but for the 5th place do you want x and 1 or just pick one of those or what?

austinandreikurt 1.xlsm
ABCD
1ValueValueCount
2xx3
31b4
4xc4
5113
6x24
7134
8b41
9b
10b
11b
12c
13c
14c
15c
162
172
182
192
203
213
223
233
244
Sheet1
Cell Formulas
RangeFormula
D2:D8D2=COUNTIF(A$2:A$24,C2)
 
Upvote 0
Hi sandy666, Your format for the toplist is what I'm looking for. I do not have the data now but this is a sample:

Book1
ABCD
1SAMPLE DATATOPRESULT
2Shirt4
3Shirt
4Pants
5Shirt
6123
7123
8Pants
9Pants
10Shirt
11Dress
12Apple
13Shirt
14Pants
15Pants
16x
17x
18x
19Shirt
20123
Sheet1
 
Upvote 0
Hi Peter, will it be possible to do both as it will still depend on the user's decision so I can easily edit it based on their requirement. Also, there should be no helper columns to count and list the unique values of the data as there will be a lot of sheets to process and it be very tedious to create a lot of helper columns.
 
Upvote 0
RawTopList
Shirt4Shirt | Pants | x | 123
Shirt
Pants
Shirt
123
123
Pants
Pants
Shirt
Dress
Apple
Shirt
Pants
Pants
x
x
x
Shirt
123

Power Query:
//not optimised
let
    Def = Excel.CurrentWorkbook(){[Name="DefTop"]}[Content]{0}[Top],
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Grp1 = Table.Group(Source, {"Raw"}, {{"Count", each Table.RowCount(_), type number}}),
    SortD = Table.Sort(Grp1,{{"Count", Order.Descending}}),
    Top = Table.FirstN(SortD,Def),
    TopList = Table.AddColumn(Top, "Top", each "Top"),
    Grp2 = Table.Group(TopList, {"Top"}, {{"Top.1", each _, type table}}),
    List = Table.AddColumn(Grp2, "List", each List.Distinct([Top.1][Raw])),
    Extract = Table.TransformColumns(List, {"List", each Text.Combine(List.Transform(_, Text.From), " | "), type text}),
    TSC = Table.SelectColumns(Extract,{"List"})
in
    TSC
 
Last edited:
Upvote 0
Hi sandy, is it possible for a simple formula? I was able to install add-in as I'm using excel at home but the office excel has a lot of restriction like downloading add-ins is not allowed, coding is not allowed, etc.
 
Upvote 0
XL2016 and all above have Power Query (Get&Transform) built-in
Add-in is required for XL2010/2013 only
if you want formula you need to wait for someone else
 
Upvote 0
is it possible for a simple formula?
No.
Certainly not with Excel 2016 & you want all the results in a single cell, including duplicates (where there could be any number of duplicates, not just two) & no helper columns & no vba.
It is a big ask for a simple formula to do a complex job. ;)

With Excel 2016 I would looking to employ a vba user-defined function or sandy666's approach.

Another possible approach is a Pivot Table filtered for top n values, but it still does not put all the results in a single cell.

austinandreikurt 1.xlsm
ABCDEFGH
1SAMPLE DATATOPRESULTRow LabelsCount of SAMPLE DATA
2Shirt4Shirt6
3ShirtPants5
4Pantsx3
5Shirt1233
6123Grand Total17
7123
8Pants
9Pants
10Shirt
11Dress
12Apple
13Shirt
14Pants
15Pants
16x
17x
18x
19Shirt
20123
Sheet2
 
Upvote 0
Mine is Excel 2016 but office excel is 2013 only. Okay, still thanks for attending the question. I can create the VBA codes myself unfortunately, vba is not an option to us. I'll be waiting then for a working formula just in case. Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,031
Members
449,205
Latest member
Eggy66

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