Reverse INDEX MATCH MATCH search

Alhelor

New Member
Joined
Jun 15, 2017
Messages
29
Honestly, it's hard to believe a solution as easy as the one I'm asking for doesn't exist on the internet (spent 1h googling), but here it goes:

Consider this table:

Gi0G442.png


Now, if we wanted to look up what a combination of R1 and C1 gives us, that would be a simple INDEX MATCH MATCH.

But what if we know R1, A2, and want the function to return C1, C3? How do you do this "reverse search"?

Please help :rolleyes:
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this:


Excel 2010
ABCDEFGHIJ
1C1C2C3C4Y-ValueR1X-Values
2R1A2A1A2A3Table ValueA2C1
3R2A1A2A1A1C3
4R3A1A1A1A3
5R4A2A2A1A3
Sheet1
Cell Formulas
RangeFormula
J2{=IFERROR(INDEX($B$1:$E$1,SMALL(IF(($A$2:$A$5=$H$1)*($B$2:$E$5=$H$2),COLUMN($B$1:$E$1)-(COLUMN($B$1)-1)),ROWS($A$1:$A1))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Just for the fun of it, you can also mimic the colors in your table through 3 Conditional Formatting rules.

Highlight A2:A5 > Conditional Formatting > Highlight Cell Rules > Equal to > $H$1 > Custom Format > Green Fill > OK > OK

Highlight B1:E1 > Conditional Formatting > New Rule > Use a formula > =COUNTIF($J2:$J5,B1) > Format > Orange Fill > OK > OK

Highlight B2:E5 > Conditional Formatting > New Rule > Use a formula > =AND($A2=$H$1,B2=$H$2) > Format > Blue Fill > OK > OK

The result will look like this:


Excel 2010
ABCDEFGHIJ
1C1C2C3C4Y-ValueR2X-Values
2R1A2A1A2A3Table ValueA1C1
3R2A1A2A1A1C3
4R3A1A1A1A3C4
5R4A2A2A1A3
Sheet1
 
Upvote 0
Thank you for your responses!

@falcon: while your formula does what it's supposed to do, I want to use that array further to match against other things without "printing" it out. The idea is that the function should return an array that I could use as follows:
SMALL(IF(array=array1_on_some_other_sheet;array2_on_some_other_sheet;"");1)

The way your formula works you can't just replace "array" in the formula above with it. Is there another way?
 
Upvote 0
Here is an example of finding the first smallest value (based on a lookup table) without producing a list of matching X-Values.


Excel 2010
ABCDEFGHIJK
1C1C2C3C4Y-ValueR2X-Value# Value
2R1A2A1A2A3Table ValueA1C12
3R2A1A2A1A1C21
4R3A1A1A1A3Min2C33
5R4A2A2A1A3C44
Sheet1
Cell Formulas
RangeFormula
H4{=SMALL(IF((A2:A5=H1)*(B2:E5=H2),TRANSPOSE(K2:K5)),1)}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hey Falcon, thanks for the response!

However, my real case looks more like this:

1jc1wz7.png


So, as you see, it's not sorted/in order. Also, C3 and C1 come up twice, and one of the number cells is empty (and should be disregarded/not taken as 0). The result should be 1.

Any chance you can solve this ultimate task? :p
 
Last edited:
Upvote 0
I understand what you are now trying to do but I am not sure how to do it without using the "helper table" in M1:N5.


Excel 2010
ABCDEFHIJKLMN
1C1C2C3C4R1C32MatchesMin Value
2R1A2A1A2A3A2C21C15
3R2A1A2A1A1F55C31
4R3A1A1A1A3C15
5R4A2A2A1A3C31
6G87
7C1Min1
8C49
Sheet1
Cell Formulas
RangeFormula
N7=MIN(N2:N5)
N2{=IF(M2="","",MIN(IF((J$1:J$8=M2)*(K$1:K$8<>""),K$1:K$8)))}
M2{=IFERROR(INDEX($B$1:$E$1,SMALL(IF(($A$2:$A$5=$H$1)*($B$2:$E$5=$H$2),COLUMN($B$1:$E$1)-(COLUMN($B$1)-1)),ROWS($A$1:$A1))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Thanks for trying, but I need it in one formula, so I can pull it down for multiple tests in a much larger set of data. :confused:
 
Upvote 0
Maybe...


A
B
C
D
E
F
G
H
I
J
K
1
C1​
C2​
C3​
C4​
Y​
R1​
C3​
2​
2
R1​
A2​
A1​
A2​
A3​
Value​
A2​
C2​
1​
3
R2​
A1​
A2​
A1​
A1​
F5​
5​
4
R3​
A1​
A1​
A1​
A3​
Result​
C1​
5​
5
R4​
A2​
A2​
A1​
A3​
1​
C3​
1​
6
G8​
7​
7
C1​
8
C4​
9​
9

Array formula in G5
=MIN(IF(ISNUMBER(MATCH($J$1:$J$8,IF(MMULT(COLUMN($B$2:$E$5)^0,($A$2:$A$5=H1)*($B$2:$E$5=H2)),$B$1:$E$1),0)),IF($K$1:$K$8<>"",$K$1:$K$8)))
Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0
I think this simpler formula also works

=MIN(IF(ISNUMBER(MATCH($J$1:$J$8,IF(INDEX($B$2:$E$5,MATCH(H1,$A$2:$A$5,0),0)=H2,$B$1:$E$1),0)),IF($K$1:$K$8<>"",$K$1:$K$8)))
Ctrl+Shift+Enter

M.
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,834
Members
449,192
Latest member
mcgeeaudrey

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