Forum Discussion
VLOOKUP to the left
Hi,
I have windows 10 and Excel 2016
I came across this formula on for VLOOKUP to the left but didn’t understand it
VLOOKUP(F7,IF({1,0},D:D,B:B),2,0)In both these cases the destination column is the second one in braces and 2 is the column index number
Of course i understand that INDEX / MATCH and XLOOKUP is a better option but i just wanted to understand the Concept of why IF function works without a true and false entry in this case.
My intention is to clear any misconceptions and learn new concepts since you are extremely good at breaking down the formula and explaining it
Also on similar lines i tried using the offset function to generate the same array in the table field in the VLOOKUP function (details in the attachment)
5 Replies
- gufygozaliCopper Contributor
this is an array formula inside logical_test IF,
{1,0} or {1\0} represent {TRUE,FALSE} or {TRUE\FALSE}since logical_test {1,0} is an array, formula IF will excecute 1 (or TRUE) and 0 (or FALSE), it's mean D:D and E:E will show, and it will create table_array D:E for VLOOKUP
IF({1,0},G8:G19,E8:E19) is a sneaky way to return a range of two columns where the second column is to the left of the first column.
{1,0} is an array of two values. It causes IF to return two results, 1 is equivalent to TRUE, so this causes IF to return the value_if_true: G8:G19. 0 is equivalent to FALSE, so it causes IF to return the value_if_false: E8:19.
If you have Microsoft 365 or Office 2021, you can use
=XLOOKUP(F7,G18:G19,E8:E19)
In all versions, a non-sneaky but longer equivalent is
=INDEX(E8:E19,MATCH(F7,G8:G19,0))
OFFSET(D7,ROW(D7:D17)-ROW(D6),COLUMN(H7)-COLUMN(E7:G7)) evaluates to a single value, not to an array.
- hussain_786_23Copper Contributor
OFFSET(D7,ROW(D7:D17)-ROW(D6),COLUMN(H7)-COLUMN(E7:G7)) evaluates to a single value, not to an array.
When i pressed F9 on this part in the table_array part and pressed enter it evaluated correctly
Yes, but not in the final formula. Perhaps someone else can explain that.
- Yea_SoBronze Contributor
VLOOKUP(F7,IF({1,0},D:D,B:B),2,0)
F7=lookup value
IF({LOOKUPCELL IS TRUE(1),0},THEN LOOKUP RANGE=D:D, RETURN RANGE=B:B ELSE IF IT IS BLANK RETURN A ZERO
range D:D = lookup range
range B:B = return value range
2= can only be a value of 2 or 1
0= exact match