4th most common text value

sparkd

New Member
Joined
Jul 23, 2018
Messages
12
I currently have the following formula to capture the 3rd most common text value from a range.
I cant seem to change this in order to capture the 4th most common text value


=INDEX(S19:S52,MODE(IF(((S19:S52<>"")*(S19:S52<>INDEX(S19:S52,MODE(IF(S19:S52<>"",MATCH(S19:S52,S19,S52,0)))))*(S19:S52<>INDEX(S19:S52,MODE(IF((S19:S52<>"")*(S19:S52<>INDEX(S19:S52,MODE(IF(S19:S52<>"",MATCH(S19:S52,S19:S52,0))))),MATCH(S19:S52,S19:S52,0)))))),MATCH(S19:S52,S19:S52,0))))
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
8,996
First, you have a typo in your formula. In the first MATCH, you have S19,S52 when it should be S19:S52. Next, changing it to capture the 4th most common would be somewhat painful. Using the same logic, you'd have to add another set of INDEX/MODE/MATCH/MATCH functions. I'd suggest something like the formula in T19 where you just drag it down to get the most common values in order.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>Q</th><th>R</th><th>S</th><th>T</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">18</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Most common values</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">19</td><td style=";">d</td><td style="text-align: right;;"></td><td style=";">a</td><td style=";">c</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">20</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">a</td><td style=";">a</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">21</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">a</td><td style=";">d</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">22</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">b</td><td style=";">e</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">23</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">b</td><td style=";">f</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">24</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style=";">b</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">25</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style=";">x</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">26</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style=";">z</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">27</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style=";">y</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">28</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">d</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">29</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">e</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">30</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">e</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">31</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">32</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">d</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">33</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">a</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">34</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">e</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">35</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">d</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">36</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">c</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">37</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">x</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">38</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">y</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">39</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">x</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">40</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">z</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">41</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">a</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">42</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">43</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">f</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">44</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">f</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">45</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">f</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">46</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">47</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">z</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">48</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">49</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">50</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">51</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">52</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet2</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Q19</th><td style="text-align:left">{=INDEX(<font color="Blue">S19:S52,MODE(<font color="Red">IF(<font color="Green">(<font color="Purple">(<font color="Teal">S19:S52<>""</font>)*(<font color="Teal">S19:S52<>INDEX(<font color="#FF00FF">S19:S52,MODE(<font color="Navy">IF(<font color="Blue">S19:S52<>"",MATCH(<font color="Red">S19:S52,S19:S52,0</font>)</font>)</font>)</font>)</font>)*(<font color="Teal">S19:S52<>INDEX(<font color="#FF00FF">S19:S52,MODE(<font color="Navy">IF(<font color="Blue">(<font color="Red">S19:S52<>""</font>)*(<font color="Red">S19:S52<>INDEX(<font color="Green">S19:S52,MODE(<font color="Purple">IF(<font color="Teal">S19:S52<>"",MATCH(<font color="#FF00FF">S19:S52,S19:S52,0</font>)</font>)</font>)</font>)</font>),MATCH(<font color="Red">S19:S52,S19:S52,0</font>)</font>)</font>)</font>)</font>)</font>),MATCH(<font color="Purple">S19:S52,S19:S52,0</font>)</font>)</font>)</font>)}</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">T19</th><td style="text-align:left">{=IFERROR(<font color="Blue">INDEX(<font color="Red">$S$19:$S$52,MODE(<font color="Green">IF(<font color="Purple">$S$19:$S$52<>"",IF(<font color="Teal">COUNTIF(<font color="#FF00FF">$T$18:$T18,$S$19:$S$52</font>)=0,MATCH(<font color="#FF00FF">$S$19:$S$52,$S$19:$S$52,0</font>)*{1,1}</font>)</font>)</font>)</font>),""</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

Let us know if this works for you.
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
8,996
After a little thought, I came up with this array formula that will return the nth most common value without needing the previous values:

=IFERROR(INDEX($S:$S,MOD(LARGE(IF($S$19:$S$52<>"",IF(MATCH($S$19:$S$52,$S$19:$S$52,0)=ROW($S$19:$S$52)-ROW($S$19)+1,COUNTIF($S$19:$S$52,$S$19:$S$52)+ROW($S$19:$S$52)/1000)),4),1)*1000),"")

Confirm with Control+Shift+Enter. Change the red 4 to the value you want. In case of ties, this lists the bottommost first, whereas my previous formula lists the topmost first.
 

Forum statistics

Threads
1,082,318
Messages
5,364,518
Members
400,804
Latest member
davileal

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top