How To VLOOKUP Multiple Values Using QUERY Function In Google Sheets ?

VLOOKUP Multiple Values Using QUERY Function

Sometimes we have to display or VLOOKUP multiple values in a row from a dataset . In this post i am going to tell you how to do that using QUERY Function in Google Sheets.

VLOOKUP Multiple Values Using QUERY Function

Let's Start With an Example

We have a dataset of two columns with Buyer Name and Item Code what they have purchased . See the picture below.

List of Two Columns

In this list the same buyer purchased more than two items , and now i want to display item codes in a row that have a buyer purchased .

1. Let’s assume i want to see the item codes of a buyer with Name Anil .

=QUERY($A:$B,"select B where A='Anil'",0)

Query Formula With Multiple Values

This formula return me a list of item codes in column.

2. To display this list in a row i add TRANSPOSE formula like this -

=TRANSPOSE(QUERY($A:$B,"select B where A='Anil'",0))

This formula return me list horizontally .

Transpose List

3. Now connect Name value to a cell 

=TRANSPOSE(QUERY($A:$B,"select B where A="""&D2&""" ",0))

Connect Name To Cell In Google Sheets

4. Now you can fill name in cell D2 and this returns the item codes of buyer .

5.To fill the formula down hold the cell corner and drag it down.

Fill Formula Down

6. You can also limit the displaying values by adding limit -

=TRANSPOSE(QUERY($A:$B,"select B where A="""&D2&""" limit 2",0))

Query LIMIT Formula

No comments:

Post a Comment