Return most common, 2nd most common, 3rd most common, etc. text string in an array

bdkyzer

New Member
Joined
Oct 26, 2012
Messages
4
I have a table of data [Table_CQI_Contacts_be.accdb] of which one column [Provider Name] has text strings. My goal is to write a formula that looks in this column of data and returns the following:

Most Common Text String
2nd Most Common Text String
3rd Most Common Text String
.
.
.
20th Most Common Text String

Sometimes the column contains a blank field some I've incorporated a conditional IF statement using the ISBLANK function. To try and get to the most common text string I've been trying to use the MODE or LARGE functions but to no avail. I think the MODE.MULT function in EXCEL 2010 is exactly what I"m looking for but I'm in EXCEL 2007.

Here is the arrary formula that I"ve been trying to use thus far and it does work for finding the Most Common Text String, but I can't get it to work for the 2nd, 3rd, etc.

Code:
=IF(ISBLANK(Table_CQI_Contacts_be.accdb[Provider Name]),"",INDEX(Table_CQI_Contacts_be.accdb[Provider Name],MATCH(LARGE(COUNTIF(Table_CQI_Contacts_be.accdb[Provider Name],Table_CQI_Contacts_be.accdb[Provider Name]),large_seq_count),COUNTIF(Table_CQI_Contacts_be.accdb[Provider Name],Table_CQI_Contacts_be.accdb[Provider Name]),0)))

The named range [large_seq_count] is an integer listing 1,2,3,4...20 for the formula to reference when fulfilling the (k) component of the LARGE formula.

Again, I'm running EXCEL 2007 and any help is much appreciated.
 
This is a better example of Post#10

Note the change in B2, +((1/ROW())/10)

Excel Workbook
ABCDE
1Data Set:HelperNameOccurrences
2Harmon Harmon3
3SmithSmith3
4SmithWilliams3
5Harmon
6Harmon3.0167
7Williams
8Smith3.0125
9Williams
10Williams3.0100
11
Sheet1
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try this...

Sheet1

ABC
2Harmon_____Williams
3SmithSmith
4SmithHarmon
5Harmon
6Williams
7Williams
8Smith
9Williams
10Williams

<tbody>
</tbody>

Enter this array formula** in C2:

=IFERROR(INDEX(A2:A10,MODE(MATCH(A2:A10,A2:A10,0)+{0,0})),"")

Enter this array formula** in C3 and copy down until you get blanks:

=IFERROR(INDEX(A$2:A$10,MODE(IF(COUNTIF(C$2:C2,A$2:A$10)=0,MATCH(A$2:A$10,A$2:A$10,0)+{0,0}))),"")

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Hey T. Valco,
I've been trying to replicate your solution above but only include names where B is TRUE and am not having any luck. any assistance would be fantastic.
Using excel 2010

ABC
2HarmonTRUE_____
3SmithTRUE
4SmithTRUE
5HarmonTRUE
6WilliamsFALSE
7WilliamsFALSE
8SmithTRUE
9WilliamsFALSE
10WilliamsTRUE

<tbody>
</tbody>

Cheers
 
Last edited:
Upvote 0
Hi T Valko - thanks for the Array formula, I think this is the start of what I need & I was wondering if you might be able to help as I am having difficulty figuring this out. I have two worksheets: Sheet 1 has a list of names in Col A and Sheet 2 has a very long list with the same names (many listed multiple times) and Col B has different values. I would like to map the most commonly occurring value in Col B for each of the values in Col A to each of their respective names in Col A in Sheet A. The example below might be more clear:
Desired Results:
Sheet 1Sheet 2Sheet 1
Col ACol ACol BCol A Col B Col C
MaryMarywhiteMary yellow white
JoeMaryyellowJoe black black (or "")
LauraJoeblackLaura blue red (doesn't matter the order of these since same # of occurences)
BillBillblueBill green blue
SteveJoeblackSteve green green (or "")
Billgreen
Billgreen
Billgreen
Laurablue
Stevegreen
Maryyellow
Joeblack
Joeblack
Marywhite
Laurared
Maryyellow

<tbody>
</tbody>

I'm not really concerned with how many times or which names in Col A are the most commonly repeated, but rather which values in Col B are the most commonly occurring for each of the names in Col A (if that makes sense....)

Thank you in advance!!
Vanessa
 
Last edited:
Upvote 0
Hi Vanessa

Maybe this

Sheet2
A
B
1
Name​
Color​
2
Mary​
white​
3
Mary​
yellow​
4
Joe​
black​
5
Bill​
blue​
6
Joe​
black​
7
Bill​
green​
8
Bill​
green​
9
Bill​
green​
10
Laura​
blue​
11
Steve​
green​
12
Mary​
yellow​
13
Joe​
black​
14
Joe​
black​
15
Mary​
white​
16
Laura​
red​
17
Mary​
yellow​

<tbody>
</tbody>



Sheet1

A
B
C
1
Name​
Color1​
Color2​
2
Mary​
yellow​
white​
3
Joe​
black​
4
Laura​
blue​
red​
5
Bill​
green​
blue​
6
Steve​
green​

<tbody>
</tbody>


Array formula in B2 copied across and down
=IFERROR(INDEX(Sheet2!$B$2:$B$17,MATCH(LARGE(IF(Sheet2!$A$2:$A$17=$A2,IF(ISNA(MATCH(Sheet2!$B$2:$B$17,$A2:A2,0)),MATCH(Sheet2!$B$2:$B$17,Sheet2!$B$2:$B$17,0))),1),IF(Sheet2!$A$2:$A$17=$A2,IF(ISNA(MATCH(Sheet2!$B$2:$B$17,$A2:A2,0)),MATCH(Sheet2!$B$2:$B$17,Sheet2!$B$2:$B$17,0))),0)),"")

confirmed with Ctrl+Shift+Enter, not just Enter

Hope this helps

M.
 
Upvote 0
Thank you so much!! This is excellent, works like a charm. I really appreciate the quick reply, too!!

Cheers!
Vanessa
 
Upvote 0
I have a similar issue I would like help solving, I have a set of data in one sheet that covers 3 Fiscal years FY15, FY16 and FY17 (named Open_FY) and sub categories of issues (named SubCat) this are workplace issues like Hostile Work Environment, Dignity and Respect, Theft... so in another sheet I layout the data in tables and charts and one table is the top 5 subcategories by Open_FY...

I can get the Top 5 for the over all date with this formula: =INDEX(SubCat,MATCH(LARGE(FREQUENCY(MATCH(SubCat,SubCat,0),ROW(SubCat)-ROW('FY16-FY17 Recieved'!$M$1)+1)+ROW('Prepared Foods FY16-FY17.xlsx'!SubCat_Plus1)/10000,ROWS(R$109:R109)),FREQUENCY(MATCH(SubCat,SubCat,0),ROW(SubCat)-ROW('FY16-FY17 Recieved'!$M$1)+1)+ROW(SubCat_Plus1)/10000,0)))

But can't find a way to get the correct Top 5 by Open_FY, an ideas? Thank you
 
Upvote 0
Welcome to Mr Excel forum

This is an old thread.
To improve your chances of getting help you should create a new thread including a small data sample and expected results.

M.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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