Index-Match with Variable Match Column

wiz329

New Member
Joined
Jun 4, 2014
Messages
43
This one has me stumped.

Suppose I have a list of Locations with rankings according to different criteria (this is my "data table"):

Sheet Name: "Data Sheet"

ABCD
1Location
Ranking Criteria #1Ranking Criteria #2Ranking Criteria #3
2Entity #11
23
3Entity #2232
4Entity #3311

<tbody>
</tbody>


Now, suppose I have an output table on another sheet:

Sheet Name: "Output Sheet"

ABCD
1RankingEntity for Criteria #1Entity for Criteria #2Entity for Criteria #3
21Entity #1Entity #3Entity #3
32Entity #2Entity #1Entity #2
43Entity #3Entity #2Entity #1

<tbody>
</tbody>


Basically, I need the formula to return the cells in red letters, but I can't quite figure it out. It seems to be a trivial Index-Match formula. However, since I want a *single formula* (rather than a separate one for each column in the output sheet), I'm not quite sure how to do it -- it seems like it would require a variable columns against which to match (B, C, or D on "Data Sheet", depending on which Criteria we are using).

In other words, I want to input the Criteria Name and the Rank, and receive the Entity Name as output. Let me know if this doesn't make sense.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
EDIT:

I realize I could reorganize "Data Sheet" as follows, and lookup Column C from the combination of A and B:

ABC
1CriteriaRankEntity
2Ranking Criteria #11Entity #1
3Ranking Criteria #12Entity #2
4Ranking Criteria #13Entity #3
5Ranking Criteria #21Entity #3
6Ranking Criteria #22Entity #1
7Ranking Criteria #23Entity #2
8Ranking Criteria #31Entity #3
9Ranking Criteria #32Entity #2
10Ranking Criteria #33Entity #1

<tbody>
</tbody>

However, this would require significant effort to reorganize the data, and I'd really like to see if there's a good way to pull the data I need in it's current format.

Thanks in advance.
 
Upvote 0
Try this, copied down and across...
=INDEX($A$2:$A$4,MATCH(SMALL(B$2:B$4,ROWS($A$1:A1)),B$2:B$4,0))

I did this on the same sheet, you just need to add the sheet names, if needed
 
Upvote 0
Not 100% sure I follow without the sheet names. Also, would this work if the Ranking Criteria Columns were out of order?
 
Upvote 0
You mentioned that you had the data on 1 sheet, and wanted the answers on a 2nd sheet, so this would refer to another sheet...
=INDEX(Sheet2!$A$2:$A$4,MATCH(SMALL(Sheet2!B$2:B$4,ROWS(Sheet2!$A$1:A1)),Sheet2!B$2:B$4,0))

The order would make no difference, it is looking for the smallest, then 2nd smallest, etc.

=SAMLL() works this way...
=SMALL(range,x) where x is the n-th smallest value you want
=SMALL(range,1) will give the smallest
=SMALL(range,2) will give the 2nd smallest
=SMALL(range,3) will give the 3rd smallest

To give a "sequential" list of "smalls", I used the ROWS() function
=ROWS($A$1:A1) = 1
=ROWS($A$1:A2) = 2
=ROWS($A$1:A3) = 3
 
Upvote 0
Excel Workbook
ABCD
1LocationRanking Criteria #1Ranking Criteria #2Ranking Criteria #3
2Entity #1123
3Entity #2232
4Entity #3311
Data Sheet



My suggestion is to change the headings in the 'Output' sheet to be the same as in the 'Data Sheet' though their order is not relevant (I have changed the order below).

Formula in B2 is copied across and down.

Excel Workbook
ABCD
1RankingRanking Criteria #2Ranking Criteria #1Ranking Criteria #3
21Entity #3Entity #1Entity #3
32Entity #1Entity #2Entity #2
43Entity #2Entity #3Entity #1
Output Sheet
 
Upvote 0
Is there an easy way to communicate with actual workbooks?

While working it out myself, I ended up using Index-Match with an INDIRECT thrown in there:

=INDEX('Data Sheet'!$A$2:$A$4,MATCH($A2, INDIRECT("'Data Sheet'!"&SUBSTITUTE(ADDRESS(1,MATCH(B$1,'Data Sheet'!$A$1:$D$1,0),4),"1",)&"2:"&SUBSTITUTE(ADDRESS(1,MATCH(B$1,'Data Sheet'!$A$1:$D$1,0),4),"1",)&"4"),0))

However, I'm curious to see how your way (which is obviously more concise) works. The problem I see is that the end of your MATCH function (the array against which you are finding the match) is that if you only wanted to output a subset of the criterias, it wouldn't work.

My implementation of that way is the following:

=INDEX('Data Sheet'!$A$2:$A$4,MATCH('Output 2'!$A2,'Data Sheet'!C$2:C$4,0))

But it only works if I include all criterias, and in the same order.
 
Upvote 0
@Peter_XXs, that's brilliant, exactly what I was looking for, and much simpler than my INDIRECT solution.
 
Upvote 0
Data Sheet

ABCD
1LocationRanking Criteria #1Ranking Criteria #2Ranking Criteria #3
2Entity #1123
3Entity #2232
4Entity #3311

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:71px;"><col style="width:131px;"><col style="width:131px;"><col style="width:131px;"></colgroup><tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


My suggestion is to change the headings in the 'Output' sheet to be the same as in the 'Data Sheet' though their order is not relevant (I have changed the order below).

Formula in B2 is copied across and down.

Output Sheet

ABCD
1RankingRanking Criteria #2Ranking Criteria #1Ranking Criteria #3
21Entity #3Entity #1Entity #3
32Entity #1Entity #2Entity #2
43Entity #2Entity #3Entity #1

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:66px;"><col style="width:136px;"><col style="width:136px;"><col style="width:136px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B2=INDEX('Data Sheet'!$A$2:$A$4,MATCH($A2,INDEX('Data Sheet'!$B$2:$D$4,0,MATCH(B$1,'Data Sheet'!$B$1:$D$1,0)),0))

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Would you mind decomposing and explaining your formula?

I've never used an Index formula with the ROW NUMBER as 0?
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,565
Members
449,038
Latest member
Guest1337

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