Lookup Value from different tables (references)

zinah

Active Member
Joined
Nov 28, 2018
Messages
368
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have below table that I need to fill the Min-Max ranges from a different 2 tables/references based on ID. I have added the Expected results column but I need a formula that can give me these results.

From below data: if ID is found in Range 1 table then give me the min & max for this ID in this format (Min-Max), if ID is not found in Range 1 then check Range 2 table and give me the results. since min and max in Range 2 table are all n/a then the result for any ID is n/a and if ID is not found in both ranges the expected result is n/a as well.

Test File_LookupValue.xlsx
ABCDEFGHIJKLMNOPQ
1IDRange TypeExpected Results (Min-Max)
2034Range 116% - 20%Range 1Range 2
3035Range 117% - 21IDMinMidMaxIDMinMidMax
4036Range 118% - 22%
5037Range 119% - 23%0035%7%9%040n/an/an/a
6030Range 114% - 18%0056%8%10%041n/an/an/a
7031Range 115% - 19%0067%9%11%042n/an/an/a
8040Range 2n/a0078%10%12%043n/an/an/a
9071Range 2n/a0089%11%13%044n/an/an/a
10072Range 2n/a00910%12%14%045n/an/an/a
11073Range 2n/a01011%13%15%046n/an/an/a
12074Range 2n/a01112%14%16%047n/an/an/a
13035Range 117% - 2101213%15%17%048n/an/an/a
14036Range 118% - 22%03014%16%18%049n/an/an/a
15068Range 2n/a03115%17%19%068n/an/an/a
16076Range 120% - 24%03416%18%20%069n/an/an/a
17077Range 121% - 25%03517%19%21%070n/an/an/a
18071Range 2n/a03618%20%22%071n/an/an/a
19097NAn/a03719%21%23%072n/an/an/a
20098NAn/a07620%22%24%073n/an/an/a
2107721%23%25%074n/an/an/a
22
23
Sheet1
Cell Formulas
RangeFormula
J5:K21J5=I5+0.02
I6:I21I6=I5+0.01
B2:B20B2=IF(ISNUMBER(XMATCH(A2,$H$5:$H$21,0)),$H$2,IF(ISNUMBER(MATCH(A2,$M$5:$M$21,0)),$M$2,"NA"))
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try something like:
Excel Formula:
=IFERROR(
TEXT(VLOOKUP($B3,$I$6:$L$22,2,0),"0 % -")&TEXT(VLOOKUP($B3,$I$6:$L$22,4,0),"0 %"),
IF(
VLOOKUP($B3,$N$6:$Q$22,2,0)="n/a",
"n/a",
TEXT(VLOOKUP($B3,$N$6:$Q$22,2,0),"0 % -")&TEXT(VLOOKUP($B3,$N$6:$Q$22,4,0),"0 %")
)
)
I tried to format the formula along the lines of DAX to make it easier to read / understand. It's actually pretty simple when you look at it: It's basically just two basic VLOOKUPs wrapped in an IFERROR. And then the VLOOKUPs are wrapped inside of a TEXT formula to show the results as a percentage. And then there's an additional IF that checks if the second set of VLOOKUPs returns "n/a" to return simply "n/a". Without it you'd get "n/an/a". Also, if your "n/a"s are actual N/A errors then you might want to use IFNA instead of the text "n/a" I'm using here.

Also, make sure the ranges match your data: I copied your data and pasted it to my workbook and didn't make sure the ranges match.
 
Upvote 0
Try something like:
Excel Formula:
=IFERROR(
TEXT(VLOOKUP($B3,$I$6:$L$22,2,0),"0 % -")&TEXT(VLOOKUP($B3,$I$6:$L$22,4,0),"0 %"),
IF(
VLOOKUP($B3,$N$6:$Q$22,2,0)="n/a",
"n/a",
TEXT(VLOOKUP($B3,$N$6:$Q$22,2,0),"0 % -")&TEXT(VLOOKUP($B3,$N$6:$Q$22,4,0),"0 %")
)
)
I tried to format the formula along the lines of DAX to make it easier to read / understand. It's actually pretty simple when you look at it: It's basically just two basic VLOOKUPs wrapped in an IFERROR. And then the VLOOKUPs are wrapped inside of a TEXT formula to show the results as a percentage. And then there's an additional IF that checks if the second set of VLOOKUPs returns "n/a" to return simply "n/a". Without it you'd get "n/an/a". Also, if your "n/a"s are actual N/A errors then you might want to use IFNA instead of the text "n/a" I'm using here.

Also, make sure the ranges match your data: I copied your data and pasted it to my workbook and didn't make sure the ranges match.
Thank you so much for your suggested solution and for taking time and explain your formula. I adjusted the formula by adding IFNA as I got #N/A for the IDs that are not found in both ranges, another issue I have is what about if I have "check" as it's showing in below table, I need to get the result "check" if I have such incident rather than the current situation "checkcheck", can you help please?


Test File_LookupValue.xlsx
ABCDEFGHIJKLMNOPQ
1IDRange TypeExpected Results (Min-Max)Suggested Formula
2034Range 116% - 20%16 % -20 %Range 1Range 2
3035Range 117% - 2117 % -21 %IDMinMidMaxIDMinMidMax
4036Range 118% - 22%18 % -22 %
5037Range 119% - 23%19 % -23 %0035%7%9%040n/an/an/a
6030Range 114% - 18%14 % -18 %0056%8%10%041n/an/an/a
7031Range 115% - 19%15 % -19 %0067%9%11%042n/an/an/a
8040Range 2n/an/a0078%10%12%043n/an/an/a
9071Range 2n/an/a0089%11%13%044n/an/an/a
10072Range 2n/an/a00910%12%14%045n/an/an/a
11073Range 2n/an/a01011%13%15%046n/an/an/a
12074Range 2n/an/a01112%14%16%047n/an/an/a
13035Range 117% - 2117 % -21 %01213%15%17%048n/an/an/a
14036Range 118% - 22%18 % -22 %03014%16%18%049n/an/an/a
15068Range 2n/an/a03115%17%19%068n/an/an/a
16076Range 120% - 24%20 % -24 %03416%18%20%069n/an/an/a
17077Range 121% - 25%CheckCheck03517%19%21%070n/an/an/a
18071Range 2n/an/a03618%20%22%071n/an/an/a
19097NAn/an/a03719%21%23%072n/an/an/a
20098NAn/an/a07620%22%24%073n/an/an/a
21077CheckCheckCheck074n/an/an/a
22
23
24
25
Sheet1
Cell Formulas
RangeFormula
J5:K20J5=I5+0.02
I6:I20I6=I5+0.01
B2:B20B2=IF(ISNUMBER(XMATCH(A2,$H$5:$H$21,0)),$H$2,IF(ISNUMBER(MATCH(A2,$M$5:$M$21,0)),$M$2,"NA"))
D2:D20D2=IFNA(IFERROR( TEXT(VLOOKUP($A2,$H$5:$K$21,2,0),"0 % -")&TEXT(VLOOKUP($A2,$H$5:$K$21,4,0),"0 %"), IF( VLOOKUP($A2,$M$5:$P$21,2,0)="n/a", "n/a", TEXT(VLOOKUP($A2,$M$5:$P$21,2,0),"0 % -")&TEXT(VLOOKUP($A2,$M$5:$P$21,4,0),"0 %") ) ),"n/a")
 
Upvote 0
You can solve the Check problem by adding yet another IF check; "IF the VLOOKUP results "Check" then return just the first "Check" otherwise return the double VLOOKUPs". I believe you can come up with the correct formula since it's quite similar to the one in my original formula: Basically all you need to do is replace the "n/a":s with "Check".
 
Upvote 0
Solution
You can solve the Check problem by adding yet another IF check; "IF the VLOOKUP results "Check" then return just the first "Check" otherwise return the double VLOOKUPs". I believe you can come up with the correct formula since it's quite similar to the one in my original formula: Basically all you need to do is replace the "n/a":s with "Check".
Thank you so much for your help, sorry I thought I replied to your comment.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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