# 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.

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

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)

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 .

3. Now connect Name value to a cell

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

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.

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

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