+ Reply to Thread
Results 1 to 3 of 3

Index/Match combined with Count

  1. #1
    Registered User
    Join Date
    02-07-2017
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1

    Index/Match combined with Count

    Hi all,

    Not sure if I am approaching this the right way and would appreciate any guidance.

    I have two columns: State and Company. There are only 50 states, but about 4000 unique companies. There are about 15,000 entries in the list overall because of various repeats. Each entry consists of the company and the associated state.

    I am trying to find which company has the most entries within each state. So, if I put "Alabama" in as the state in the toggle area, I would like the company with the most counts in the Company column to be returned, but only among those companies that have entries in "Alabama." I have tried to do this with combinations of INDEX(MODE(MATCH etc. but I'm having trouble only returning the match for a specific criteria.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Index/Match combined with Count

    You will usually find that you'll get an answer more quickly if you attach a sample sheet. However, I had a file "in stock" that matches my "best guess" for what you want.

    If there can ONLY be one maximum number per state, copied down:

    =IFERROR(INDEX($B$1:$B$48,MODE.SNGL(IF($A$1:$A$48=E2,MATCH($B$1:$B$48,$B$1:$B$48,0)))),"")

    If there can be several, this formula identifies how many tied results there are, copied down:

    =IFERROR(SUM(--(MODE.MULT(IF($A$1:$A$48=E2,MATCH($B$1:$B$48,$B$1:$B$48,0)))>0)),"")

    and this one, copied across and down identifies the tied values:

    =IFERROR(IF($G2>=COLUMNS($H:H),INDEX($B$1:$B$48,INDEX(MODE.MULT(IF($A$1:$A$48=$E2,MATCH($B$1:$B$48,$B$1:$B$48,0))),COLUMNS($H:H))),""),"")

    these are ALL array formulae.
    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Index/Match combined with Count

    Another option to consider:

    You could also achieve this using a Pivot Table, Slicers and cell reference.

    If you make the source data into an Excel Table, it will be dynamic in range - ideal for a Pivot Table.
    By setting the PT to show only the Top-X, where "X" = 1, it will always display the company with greatest count.
    You only need to reference the cell containing the company and count.

    PT do need to be refreshed when data are changed and this is easily automated with VBA.
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Combined count if and index match
    By emina002 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2016, 12:00 PM
  2. Index Match combined with blank cell
    By balabuschka in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-24-2015, 11:05 AM
  3. INDEX and MATCH(?) combined with SUM across multiple sheets
    By jusmightbeokay in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-14-2014, 06:14 AM
  4. [SOLVED] Combined INDEX and MATCH formula will not work - pls help!
    By Postlki1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-06-2013, 08:03 AM
  5. INDEX , MATCH ,INDIRECT Combined usage example - Pls
    By TKD in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-24-2012, 09:32 AM
  6. INDEX, MATCH & INDIRECT combined usage
    By TKD in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-13-2012, 07:21 PM
  7. INDEX, MATCH, and IF functions combined
    By veeeSix in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-23-2012, 01:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1