If the index column in Vlookup is generated using Hlookup or Match, then such Vlookup formula normally does a two-way Lookup. In this Google Docs Sheets guide, I am detailing how to return two column output in a two-way lookup in Google Sheets.
Want ‘n’ column output? I have that solution too! Read on to learn all these tips.
In one way lookup, I mean the traditional Vlookup, it’s quite easy to return multiple column output.
See this generic formula to generate a two column output in a Vlookup (one-way lookup). The “index columns” plays the main role in this formula to return ‘n’ column output.
=ARRAYFORMULA(VLOOKUP(search_key, range, index columns, [is_sorted]))
In this, the “index columns” (the index column numbers) can be entered within Curly Brackets as below.
{2,3}
But in such use, don’t forget to use the ArrayFormula with Vlookup. See the screenshot below to understand one-way Lookup with two column as output.
Since this is not our topic, other than the above image, I am not going into any more examples related to one-way lookup. You can read that here – Multiple Values Using Vlookup in Google Sheets is Possible.
Similarly above you can get two column output in a two-way lookup in Google Sheets.
How to Get Two Column Output in a Two-way Lookup in Google Sheets
Two column output in two way-lookup is relevant since we are unsure about the index column number.
In a two-way Lookup, we are using either the Hlookup or Match function to find the index column number.
So we can’t follow the above one-way lookup approach here (virtual index column array generated using Curly Braces). But it’s somewhat similar. I’ll come to that.
Two-way Lookup with Output from One Column
How to search down the column A for “Employee 2” and search across the row A1
I mean how to do this two-way lookup (vertical and horizontal Lookup) to return one column data?
=VLOOKUP("Employee 2",A1:G,MATCH(date(2019,1,2),A1:G1,FALSE),FALSE)
This formula would return the value 8 which is in cell D4. What I want is the values from cell D4 and E4, i.e., two column data.
As a side note, if you are new to two-way lookup, see my guide – How to Perform Two-way Lookup Using Vlookup in Google Sheets. Then come back to read further.
Two-way Lookup with Output from Two Columns
Now here is the tip to get two column output in a two-way Lookup in Google Sheets.
The below Match formula (taken from the above single column lookup returns the number 4 (that is the column number).
=MATCH(date(2019,1,2),A1:G1,FALSE)
That means index column number 4. Now see the modified Match formula. In that, I have used ArrayFormula and a virtual array using Curly Brackets.
=ArrayFormula(MATCH(date(2019,1,2),A1:G1,FALSE)+{0,1})
This formula returns the index column numbers 4 and 5. That means two columns. We can use this in two-way Lookup.
The two-way lookup formula that returns two columns will be as follows.
=ArrayFormula(VLOOKUP("Employee 2",A1:G,MATCH(date(2019,1,2),A1:G1,FALSE)+{0,1},FALSE))
Hope this makes sense.
To return multiple columns, I mean more than two columns or ‘n’ columns, you can use the formula as below.
=ArrayFormula(VLOOKUP("Employee 2",A1:G,MATCH(date(2019,1,2),A1:G1,FALSE)+{0,1,2,3},FALSE))
This Vlookup formula would return a 4 column output. But in this case, there is one more approach. That will be useful for ‘n’ column output. Find that here –Two-way Lookup and Return Multiple Columns in Google Sheets.
That’s all. Enjoy!