VLOOKUP in Power Query

While Power Query lacks a direct equivalent to Excel’s VLOOKUP function, you can use its Merge feature to achieve the same result: locate a matching value in the leftmost column of a table and retrieve a corresponding value from a column you specify. 

I will show you how to use the Power Query’s Merge feature to replicate the behavior of Excel’s VLOOKUP.

Suppose you have the Sales table below on the left and the Product table on the right on an Excel worksheet.

Data set and power query to perform VLOOKUP.

You want to use Power Query to add the ‘ProductName’ from the Products table to the Sales table by matching the ‘ProductID’ column, like how VLOOKUP works in Excel.

Here’s how to do it:

Step #1: Load the Data of Both Tables into Power Query Editor

Use the steps below to load the data of the Sales and Products tables into the Power Query Editor:

  1. Select any cell in the Sales table.
  2. Open the Data tab and click the From Table/Range command button.
Click on the front table range icon to open Power Query Editor.

The above step loads the table data into the Power Query Editor.

Data is now loaded into Power Query Editor.
  1. On the Home tab of the Power Query Editor, open the Close & Load drop-down on the Close group and select the Close and Load To option.
Click on the close and load to option in Power Query Editor.

The above step opens the Import Data dialog box.

  1. On the Import Data dialog box, select the Only Create Connection option and click OK.
Check the only create connection option in the import data dialog box.

The above step loads the table data into the Power Query Editor for transformation without immediately loading it into an Excel worksheet or the data model.

  1. Load the Product table data onto the Power Query Editor using the steps above. 

The queries you have created are listed on the Queries & Connections pane on the right of the Excel window.

Queries and connections pane

If you do not see the Queries & Connections pane, activate it by opening the Data tab and clicking the Queries & Connections command button on the Queries & Connections group.

Click on the queries and connections options in the data tab.

Step #2: Merge the Queries

Use the steps below to merge the Sales and Products queries:

  1. On the Queries & Connections pane, right-click the Sales query and select the Merge option on the shortcut menu.
Right click on the sales query and then select the merge option.

The above step opens the Merge dialog box with the Sales query already selected.

  1. On the Merge dialog box, open the second drop-down and select the Products query.
Select the products table in the merge dialog box.
  1. Select the ProductID column in both queries, choose the ‘Left Outer’ join option, and click OK.
Select the common column that will act as a key to do VLOOKUP in Power Query.

Note: A Left Outer join keeps all the rows from the left (primary) table, in this case the Sales table, and matches rows from the right (secondary) table, in this case the Products table, only when there’s a match. If no match is found, the result will include nulls for the columns from the right table.

The above steps merge the two queries into a Merge1 query and load it onto the Power Query Editor. The merged query has a Products column with a table icon on the left of the header.

A new column is added to the data.

Notice the ‘expand column’ icon on the right of the Products column header.

Step #3: Expand the Target Column  

Use the steps below to expand the ProductName column in the Merge1 query:

  1. Click the expand icon, uncheck the ‘Select All Columns’ option, select the ProductName column, uncheck the ‘Use original column name as prefix’ option, and click OK.
Click on the expand column icon.

The above steps expand the ProductName column in the merged query.

The product name column is expanded.

Move the ProductName column to the immediate right of the ProductID column by dragging its header.

Move the product name column.

Step #4: Load the Merged Query Data Back into Excel

Click the Close & Load button to load the merged query data back into Excel.

Load the data back into Excel.

You have successfully done a VLOOKUP in Power Query using the Merge feature.

I have shown you how to do VLOOKUP in Power Query. I hope you found the tutorial helpful.

Other Power Query and Excel articles you may also like:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.