Lookup multiple columns approximate match

brently

New Member
Joined
Feb 9, 2012
Messages
19
Hi,

I have data like this:

Code:
	500	a
TRUE	470	b
	440	c
TRUE	410	d
TRUE	380	e
	350	f
	320	g
TRUE	290	h
TRUE	260	i
	230	j
TRUE	200	i
TRUE	170	j

and I want to look up an approximate value in Col2, say 310, and return it's next-highest friend from Col3, in this case "g". This is easy enough with INDEX and MATCH. But I want to take it one step further and only use those values which are approved by Col1 - so in this case I want 310 to ACTUALLY return "e"

I found some good information here which gets me close. The following works very well. It uses a boolean & operator to match two values at once, but it only works for exact matches. This example goes down the list and finds the first "sydney" which has an "x" and gives the result "h".

Code:
x	melbourne	a
	sydney		b
x	adelaide	c
x	melbourne	d
	sydney		e
x	adelaide	f
x	melbourne	g
x	sydney		h
x	adelaide	i
x	melbourne	j
x	sydney		k
x	adelaide	l
		
lookup_1	x
lookup_2	sydney
formula	INDEX(A1:C12,MATCH(B14&B15,INDEX(A1:A12&B1:B12,),0),3)
result	h

When I use this approach on data like in my first example it falls over, my guess is because the boolean & falls down before the MATCH function has a chance to accept an approximate match.

Has anyone got any ideas on where I could proceed from here?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the board..

Try this array formula entered with CTRL + SHIFT + ENTER

=INDEX(C1:C12,MATCH(E1,IF(A1:A12,B1:B12),-1))

Excel Workbook
ABCDEF
1500a310e
2TRUE470b
3440c
4TRUE410d
5TRUE380e
6350f
7320g
8TRUE290h
9TRUE260i
10230j
11TRUE200i
12TRUE170j
Sheet1
 
Upvote 0
OMG one million internet points to you!!

I've been working on that all day, and you sorted me out in about 10 minutes flat.

Thank you so much kind sir!

:):)
 
Upvote 0
Hi brently,

Hope you would not mind, I have a question for jonmo1...

I find your formula very cool, what about :
=INDEX(result,MATCH(cond2, IF(data1=cond1,data2),-1))

where result is the alphabetical data in column C
cond2 is the numerical value searched (310)
cond1 is TRUE
data1 is column A
data2 is column B
http://uploading.com/files/3922mbb4/brently.xlsx/

I noticed that both formula failed if reference data2 (column B) is sorted. Any idea why?
Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,842
Messages
6,127,235
Members
449,372
Latest member
charlottedv

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