Approximate Match With XLOOKUP Two Criteria Returns Multiple Results

wsnyder

Board Regular
Joined
Sep 23, 2018
Messages
223
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to use XLOOKUP with 2 criteria to return an approximate match (Match Mode = -1)
I believe the formula below should return 1 at 0.6, but as you see, it is returning 1 at both 0.8 and 1 (Selected).
Any idea why that would be and the correct fix?

Thanks,
-w


RespRandValue
10.7973671
20.7175771

Formula:
=XLOOKUP(E3:E7,IF(tblData[Resp]=C3,tblData[Rand]),tblData[Value],0,-1)

1687904287995.png
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Some of the descriptions in the XLOOKUP help I think are misleading as it does not do an 'approximate (closest)' match.
Your 4th argument (-1), as detailed in the help means that if the value is not found, it looks for the next smaller item (not the closest item). Since there is no exact 0.6 in your data & there is no smaller value in your table, the formula is correctly returning the "if not found" value of 0.

1687922600936.png

S
 
Upvote 0
Thanks Peter,

I tried so simplify to 1 criteria by adding the weight to the Response_Nbr - now I only have 1 criteria.
I then change the XLOOKUP() to VLOOKUP with approximate match.

I'm still getting a positive response for 1.8 and 1.99 where I expect both to be a negative response.
The only positive response should be at 1.6 since the value in the lookup table is 1.797367.

Any ideas?

Book1
BC
2CellFormula
3G3=IFERROR(VLOOKUP(F3,tblData[[Resp_Rand]:[Value]],2,TRUE),0)
Sheet1


Lookup Table:

Math Analysis Table 174.xlsx
STUV
2RespRandResp_RandValue
310.7973671.7973671
420.7175772.7175771
530.3925173.3925171
640.098324.098321
750.9382865.9382861
860.9676126.9676121
970.574087.574081
1080.3828658.3828651
1190.2224339.2224331
12100.84776310.847761
13110.50202511.502031
14120.10797712.107981
15130.83659513.836591
16140.69551914.695521
17150.25491915.254921
18160.15878316.158781
19170.38806717.388071
20180.01461118.014611
21190.53071319.530711
Sheet1
Cell Formulas
RangeFormula
U3:U21U3=[@Resp]+[@Rand]
 
Upvote 0
I'm still getting a positive response for 1.8 and 1.99 where I expect both to be a negative response.
What does a 'positive response' or a 'negative response' actually mean?

You have posted a formula which refers to cell F3 but we have no idea what is in F3.
We also do not know what result that formula gave for the sample data provided.
We also do not know what result you expected/want from that formula for the sample data provided.
 
Upvote 0
Thanks Peter,

Here is my Lookup formula:
Excel Formula:
=IFERROR(VLOOKUP(F3,tblData[[Resp_Rand]:[Value]],2,TRUE),0)

In Col G of this table:
1688103515391.png


When an approximate match is found I would like to return the value of 1.
From the Lookup Table, I see the value 1.797367 (Table above - last post)
That is closest to 1.6 without going over, so at 1.6, I would like to return the value of 1 in Col G.
But that is not happening. Currently getting a value of 1 returned for 1.8 and 1.99.

Thanks,
-w
 
Upvote 0
I mentioned before in relation to XLOOKUP but VLOOKUP is similar in this respect. They do not do "approximate" match. With your formula if VLOOKUP cannot find the exact value of 1.6 (& it cannot) then it will look for the value that is lower than 1.6 but closest to 1.6
Since there is no value lower than 1.6 the VLOOKUP returns an error and so the IFERROR part of your formula kicks in and returns the zero.

You have said that you want 1 returned on the 1.6 row (ie in cell G5 in your image)
What result do you want in each of the following cells in that image, and why?
G3
G4
G6
G7

Once I know what values you expect in all 5 cells in column G then I can look at possible alternative formulas for you.
 
Upvote 0
Thanks Peter,

Since the Lookup Value 1.797367is closest to 1.6 (Cell F5) a value of 1 should be returned to Cell G5.
Since the approximate watch is returned to cell G5, all other cells in the set should be zero (G3, G4, G6, G7)

Thanks,
-w
 
Upvote 0
Since the Lookup Value 1.797367
Now I am more confused if the lookup value is 1.797367

In your earlier formula [=IFERROR(VLOOKUP(F3,tblData[[Resp_Rand]:[Value]],2,TRUE),0)] the lookup value is F3 (1.6)

What is the point of the rest of tblData if you are only looking for the closet value to the first value in that table?

Your attempted formulas are looking up something in tblData but your descriptions seems to keep looking up something (closest value) in F3:F7

I wonder if a new set of sample data and expected result would help clarify??
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,106
Members
449,096
Latest member
provoking

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