Returning the top 3 occuring text strings in a range

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
184
Office Version
  1. 365
Platform
  1. Windows
I am using these 3 formulas to return the #1, #2 and #3 top referral source, in other words the value that appears the most times, 2nd most times and 3rd most times. It has been working perfectly until I today when the #2 and #3 happened to appear the same number of times. The result is that the #2 and #3 result are returning the same name.
I tried the large formula but it relies on numerical values, my range contains strings.

Any ideas on how I can fix this or perhaps a different way of returning the top 3 occurring values in a range? is VBA the solution?

1st Most occurring Referral Source
=INDEX(T:T, 10000*MOD(MAX(COUNTIF(T11:T992,T11:T992)+(ROW(T11:T992)/10000)),1), 1)

2nd most occurring Referral Source
=INDEX(T11:T992,MODE(IF((T11:T992<>"")*(T11:T992<>INDEX(T11:T992,MODE(IF(T11:T992<>"",MATCH(T11:T992,T11:T992,0))))),MATCH(T11:T992,T11:T992,0))))

3rd most occurring Referral Source
=INDEX(T11:T992,MODE(IF(((T11:T992<>"")(T11:T992<>INDEX(T11:T992,MODE(IF(T11:T992<>"",MATCH(T11:T992,T11:T992,0)))))(T11:T992<>INDEX(T11:T992,MODE(IF((T11:T992<>"")*(T11:T992<>INDEX(T11:T992,MODE(IF(T11:T992<>"",MATCH(T11:T992,T11:T992,0))))),MATCH(T11:T992,T11:T992,0)))))),MATCH(T11:T992,T11:T992,0))))
 

Attachments

  • mec2020-05-30 11_05_54-Luis Pipeline Report V7.xlsm - Excel.png
    mec2020-05-30 11_05_54-Luis Pipeline Report V7.xlsm - Excel.png
    20 KB · Views: 46

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this for all 3 note that there are 2 instances of D$1:D1 in the formula which need to be changed, these should refer to the cell directly above the first formula before dragging down, e.g. if the formula is going into D2, then it would be D$1:D1, if it is going into Z10 then it would be Z$9:Z9

=INDEX(T:T,AGGREGATE(15,6,ROW($T$11:$T$992)/(COUNTIF($T$11:$T$992,$T$11:$T$992)=AGGREGATE(14,6,COUNTIF($T$11:$T$992,$T$11:$T$992),1+SUMPRODUCT(COUNTIF($T$11:$T$992,D$1:D1))))/ISNA(MATCH($T$11:$T$992,D$1:D1,0)),1))
 
Upvote 0
Try this for all 3 note that there are 2 instances of D$1:D1 in the formula which need to be changed, these should refer to the cell directly above the first formula before dragging down, e.g. if the formula is going into D2, then it would be D$1:D1, if it is going into Z10 then it would be Z$9:Z9

=INDEX(T:T,AGGREGATE(15,6,ROW($T$11:$T$992)/(COUNTIF($T$11:$T$992,$T$11:$T$992)=AGGREGATE(14,6,COUNTIF($T$11:$T$992,$T$11:$T$992),1+SUMPRODUCT(COUNTIF($T$11:$T$992,D$1:D1))))/ISNA(MATCH($T$11:$T$992,D$1:D1,0)),1))
Thanks, this worked perfectly, I have tried so many things for so many days and have googled every possible variation to no avail. Honestly the formula is way out of my league so thank you very much.
 
Upvote 0
I'm sure that I've done the same thing before with a much shorter formula but can't remember how. Personally, I would use a pivot table rather than a formula.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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