New Tool Radar

AI for Data & Spreadsheets

How to Merge Two Queries on a Key Column in Power Query Instead of VLOOKUP

Join a sales query to a lookup query in Power Query with Merge Queries, and check the row counts before and after.

Schematic with three steps: Start the merge and pick the key; Choose the join kind; Expand the new column and check the.

Merge Queries brings lookup columns across by matching a key, like VLOOKUP but more flexible: it can keep unmatched rows, show only non-matches, and repeat the join on every refresh. The row counts before and after the merge are the check that the join worked.

What you need

  • Excel with two queries loaded: a main table and a lookup table
  • A key column present in both, with matching types
  • A copy of the source files

Step 1: Start the merge and pick the key columns

Open Home, Merge Queries, pick the two tables and choose the matching key columns in each. Confirm the key columns have the same data type, or the match will fail silently.

Step 2: Choose the join kind

Pick Left Outer to keep all rows from the first table, or Inner to keep matches only. Left Anti keeps only the non-matches, which is the way to find rows with no lookup entry.

Step 3: Expand the new column and check the row count

Expand the merged column and pick the fields to bring in. Compare the row count before and after the merge: a Left Outer merge must not change the row count.

Worked example: synthetic sales and price list merge

The table below is a synthetic example. It shows the expected result of merging two queries; no files were imported.

Check Count Result
Sales rows before merging 100 Source
Price list rows 20 Lookup
Sales rows after merging 100 Left Outer keeps all rows
Rows with no price match 2 Flagged for follow-up

Expected result (UNTESTED). all 100 sales rows survive the Left Outer merge, 98 gain a price and 2 have no match and are flagged for follow-up. The row count is unchanged, so the join is sound. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Always check the row counts before and after a merge; a changed count means the join kind was wrong.
  • Key columns must have the same type; a text key will not match a number key.
  • Expand only the fields you need, or the table gains columns nobody asked for.

Sources

See all