Index-Match on Multiple Columns -- Nth Result

Bratamoli

New Member
Joined
Jul 20, 2018
Messages
19
Can someone help me adjust this formula to return the Nth "group" that a "name" is in? And if the "name" only occurs once, the search for the 2nd occurrence will return ""?
Sticking with the pictured example, I would like each person's 1st group to show in column H [like it already is] and each person's second group--for those that have a 2nd group--to show in column I.

In my current data-set, nearly every "name" occurs in 2 different "groups"; in my next data-set, most "names" will occur up to 6 different times.


https://exceljet.net/formula/index-and-match-on-multiple-columns said:
Code:
{=INDEX(groups,MATCH(1,MMULT(--(names=G4),TRANSPOSE(COLUMN(names)^0)),0))}

Index and match on multiple columns
<hyperlinked image="">
</hyperlinked>
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Thank you for the Reply, Aladin. :)

The original was the picture on the website I found the partial-answer on:
https://exceljet.net/formula/index-and-match-on-multiple-columns

Not sure how to "post this in an Excel readable form," so I did this.
I recreated the table in Excel and copy-pasted it to here.
You can copy-paste it back into excel and it will work.
Paste this array formula into cell H3, then fill it down through cell H14:
{=INDEX(groups,MATCH(1,MMULT(--(names=G3),TRANSPOSE(COLUMN(names)^0)),0))}

Again, the goal is to return the Nth "Group" that the name is in.
For example (and I changed the name in cell E5 for this), cell H9 should return "Fox" (the 1st group Luis is in) and I9 should return "Moose" (the 2nd group Luis is in).

A1BCDEFGHI
2GroupName 1Name 2Name 3NameGroupGroup 2
3FoxDougLuisKatyAdam
4BearAdamSusanAlexAlex
5MooseAyaMaryLuisAya
6WolfJuanVictorMiaDoug
7Juan
8Katy
9names = C3:E6Luis
10groups = B3:B6Mary
11Mia
12Rie
13Susan
14Victor

<tbody>
</tbody>


<tbody>
</tbody>
 
Upvote 0
This seems to do it.

=IFERROR(INDEX(Groups,SMALL(IF(ISNUMBER(SEARCH($G3,Names)),ROW(Groups)-1,""),COLUMN()-7)-1),"")

Array formula so Ctl+Shift+Enter
 
Last edited:
Upvote 0
It needs some troubleshooting though. :confused:
I tried to troubleshoot it myself, but I wasn't successful with it.

Here's a link to the file in Dropbox: https://www.dropbox.com/s/yad78jy781fqh4q/Pokémon GO.xlsx?dl=0

In the "Pokémon" tab, column AP (using the "exceljet.net Formula" below) looks for the character's number (from column D) in the cell-set "FMPoké" ('Fast TMs'!I6:BO68) and returns the move name from cell-set "FMs" ('Fast TMs'!C6:C68). It doesn't work for all of them yet--and it only returns the 1st result found--but the results it returns are correct. I could troubleshoot this one to work for all of them, but I really need a formula that will return each result vs. only returning the 1st result.

In the "Pokémon" tab, column AQ (using "lrobbo314's Formula" below) seems to be working except that it returns the wrong move name. [Edit: it also only works for about the first dozen rows.] Irobbo314's Formula worked perfectly in the sample spreadsheet ('Sheet 1' in my workbook) from earlier in this thread--to include showing the next "group" a "name" was in when I filled it across the other columns. I even tested it prior to my previous reply in this thread by adding a 3rd results column and changing several of the names.

exceljet.net Formula:
{=INDEX(FMs,MATCH(1,MMULT(--(FMPoké=[@['#]]),TRANSPOSE(COLUMN(FMPoké)^0)),0))}

lrobbo314's Formula:
{=IFERROR(INDEX(FMs,SMALL(IF(ISNUMBER(SEARCH([@['#]],FMPoké)),ROW(FMs)-1,""),COLUMN()-7)-1),"")}

Thank you again for your help with this.
 
Upvote 0
Try to post the correct results against which the candidate formulas including those of post #6 can be evaluated.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

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