Find most common occurrence and display it.

dad2sdt

New Member
Joined
Oct 24, 2014
Messages
8
Hi Community,

Been trying to figure this out all morning. I have a range of data, with column headers. I have computed values based on certain criteria in a range of cells Similar to the following: Lets call it clothing items.

Mon 400
Tue 300
Wed 6
Thur 7
Fri 50

I have computed this with the following formula: =COUNTIFS(Data!AN:AN,B9,Data!AI:AI,"Mon",Data!Z:Z,"SpecificText",Data!AQ:AQ,"AlternateText") replacing Tue, Wed...for Mon on each row. With this, I can see that I have sold 400 items on Monday, 300 on Tuesday...

Now out of those values, I want to display the most common occurrence of what made up that 763 items. I was trying to, unsuccessfully with the following formula based on some searches but I cannot figure it out. The goal is for Cell E26 to display the word Shirts, Pants, Shoes, based on if that is the most common thing sold that week. The item sold is in column AH of which I am trying to figure out which was sold most.

Cell E26: =INDEX(Data!AH:AH, 10000*MOD(MAX(COUNTIF(Data!AH2:AH1000000,Data!AH2:AH1000000)+(ROW(Data!AH2:AH1000000)/10000)),1), 1)

Any ideas welcomed.

Jeff

Jeff
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
9,911
It would have been helpful if you could have displayed an example of your sheets. Nevertheless, I tried to create a small sample derived from your formulas.

<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 /><col /><col /><col /><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>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>Z</th><th>AH</th><th>AI</th><th>AN</th><th>AQ</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</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><td style="text-align: right;;"></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><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Mon</td><td style="text-align: right;;">2</td><td style="text-align: right;;"></td><td style=";">Most Common</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Mon</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Tue</td><td style="text-align: right;;">3</td><td style="text-align: right;;"></td><td style=";">Shoes</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shirts</td><td style=";">Mon</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">Wed</td><td style="text-align: right;;">2</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><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Mon</td><td style=";">x</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">Thur</td><td style="text-align: right;;">1</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><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Tue</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">Fri</td><td style="text-align: right;;">3</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><td style=";">SpecificText</td><td style=";">Shoes</td><td style=";">Tue</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Shoes</td><td style=";">Tue</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Belts</td><td style="text-align: right;;"></td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;;"></td><td style=";">x</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><td style=";">SpecificText</td><td style=";">Shoes</td><td style=";">Tue</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shoes</td><td style=";">Wed</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">11</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shirts</td><td style=";">Wed</td><td style="text-align: right;;"></td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">12</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shoes</td><td style=";">Wed</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">13</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Wed</td><td style=";">x</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">14</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Belts</td><td style=";">Thur</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">15</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Fri</td><td style="text-align: right;;"></td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">16</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Pants</td><td style=";">Fri</td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">17</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shirts</td><td style=";">Fri</td><td style=";">x</td><td style=";">AlternateText</td></tr><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="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Pants</td><td style="text-align: right;;"></td><td style=";">x</td><td style=";">AlternateText</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">19</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><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">SpecificText</td><td style=";">Shoes</td><td style=";">Fri</td><td style=";">x</td><td style=";">AlternateText</td></tr></tbody></table><p style="width:3.2em;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)">Data</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)">D3</th><td style="text-align:left">{=INDEX(<font color="Blue">Data!$AH$2:$AH$1000,MODE(<font color="Red">IF(<font color="Green">ISNUMBER(<font color="Purple">MATCH(<font color="Teal">Data!$AI$2:$AI$1000,{"Mon","Tue","Wed","Thur","Fri"},0</font>)</font>),IF(<font color="Purple">$Z$2:$Z$1000="SpecificText",IF(<font color="Teal">$AQ$2:$AQ$1000="AlternateText",IF(<font color="#FF00FF">$AN$2:$AN$1000=B9,IFERROR(<font color="Navy">MATCH(<font color="Blue">$AH$2:$AH$1000,$AH$2:$AH$1000,0</font>),""</font>)</font>)</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 />

If this is close, then you can use the D3 formula to find the most common item type. You'll need to adjust the formula for your sheets.
 

dad2sdt

New Member
Joined
Oct 24, 2014
Messages
8
Thanks, Eric. I will play around with this over the next day or so and post back with real world data/progress.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,630
Messages
5,488,004
Members
407,617
Latest member
Samanthad2007

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top