Ravindra BagaleCourses & study guides मराठी Track your progress

10. Power Query in Excel

10.5 Merge Queries

Merge queries (Left Outer) with example — in 30 seconds

What: Merge joins two queries on a matching column, like XLOOKUP but inside Power Query.

Why: The join is saved as a step. Next month you press Refresh and the manager names come again.

Tiny example: Orders and Stores are merged on Store ID. BLK-PUN-09 is missing from Stores, so its manager is null.

First look at the data (before → after):

Merge queries (Left Outer) with example: before and after tables, fictional FreshGo Maharashtra data

Expected result — Orders with City Manager

Order ID Store ID Amount City Manager
BLK-1101 BLK-PUN-01 64 Ravindra Bagale
AMN-1102 AMN-SLP-01 1299 Salman
BLK-1103 BLK-PUN-09 150 null

About this data: Made-up QuickCart order IDs matched to a Pune rider master. Fictional names and cities.

Before table and formula as text

Before — Query: Orders

Order ID Store ID Amount
BLK-1101 BLK-PUN-01 64
AMN-1102 AMN-SLP-01 1299
BLK-1103 BLK-PUN-09 150

About this data: Left and right sample tables before a Merge — teaching data only.

Before — Query: Stores (part)

Store ID City Manager
BLK-PUN-01 Ravindra Bagale
BLK-PUN-02 Shraddha Bagale
AMN-SLP-01 Salman

About this data: Merge result preview with matching keys. Not real customer data.

Formula / click path

Home › Merge Queries › Orders + Stores on Store ID
Join Kind: Left Outer · expand City Manager

Do it step by step:

  1. Select the Orders query and click Home › Merge Queries.
  2. Click Store ID in Orders, choose Stores below, and click Store ID there.
  3. Keep Join Kind: Left Outer and click OK.
  4. Click the expand icon on the new column and tick only City Manager.
  5. Filter for null to find stores missing from the master.

Merge = join two tables on a key column (like XLOOKUP, but for whole tables and many columns).

Join kind Returns Typical use
Left Outer (default) All rows from first, matches from second Add store details to orders
Right Outer All rows from second, matches from first
Full Outer All rows from both Reconciliation
Inner Only matching rows Orders of known stores only
Left Anti Rows in first with no match Orders with Store ID missing in master
Right Anti Rows in second with no match Stores with no orders

About this data: Join-kind reminder table (Left Outer, Inner, etc.) with short plain-English meanings.

Steps in Excel

  1. Select the All_Orders query › Home › Combine › Merge Queries (or as New).
  2. Top table: All_Orders, click the Store ID column. Bottom table: Stores, click Store ID.
  3. Join Kind: Left Outer › OK. The status bar shows how many rows matched.
  4. A new column Stores with Table values appears › click the expand icon (↔) › tick City Manager and Manager Email › untick Use original column name as prefix › OK.
  5. Data-quality check: merge again with Left Anti to list orders whose Store ID is missing in the master.
  6. City mapping: merge the City column with the CityMap query (5.5) on the lower-case trimmed name.

Ravindra Bagale's Tip

"The rows increased after the merge" – many students experience this. The reason is a duplicate key in the lookup table (the same Store ID twice) – so every order appears twice. Before merging, do Remove Duplicates (on the key column) in the lookup table, and compare the row count after the merge.

Worked example — add city names to QuickCart orders with Merge

Why

Your Orders sheet has RiderID but not City. A second Riders sheet has the city. Merging saves a slow VLOOKUP copy-paste every morning.

What

Power Query Merge joins two queries on a key column (like SQL join / XLOOKUP for tables).

How

  1. Load Orders (OrderID, RiderID, Amount ₹) and Riders (RiderID, RiderName, City) as two queries.
  2. On Orders choose Home → Merge Queries.
  3. Pick Riders as the second table. Click RiderID on both sides.
  4. Join Kind: Left Outer (keep all orders). OK.
  5. Expand the new column → tick RiderName and City → OK → Close & Load.

Formula

Merge Orders ⋈ Riders on RiderID (Left Outer)
Result: Every order keeps its ₹ amount and gains City (Pune, Nashik, …). Orders with no rider stay, City blank.
Meaning: Left Outer Merge = keep all left rows, bring matching columns from the right. Same idea as XLOOKUP down a column, but for whole tables.

Practice tasks (10+)

Try these on a blank sheet. Open a hint only if you are stuck. No quiz — just practice.

1. Merge Orders to Riders on RiderID with Left Outer.

Hint: Home → Merge Queries. Select the same key on both sides.

2. Show only matching rows (Inner join).

Hint: Change Join Kind to Inner. Rows without a match disappear.

3. Expand City and RiderName after the merge.

Hint: Click the expand icon on the new column. Untick RiderID if it duplicates.

4. Find orders whose RiderID is missing in Riders (Left Anti).

Hint: Join Kind → Left Anti. Good for data-quality checks.

5. Merge a Prices table (€) to a Berlin store Orders table on SKU.

Hint: Same Merge idea — key is SKU, not RiderID.

6. Why use Merge instead of VLOOKUP for 50,000 rows?

Hint: Think about refresh, steps, and wide tables.

7. After Merge, change a city in Riders and refresh.

Hint: Data → Refresh All. The city on Orders should update.

8. Merge on two keys: City + Product.

Hint: Hold Ctrl to select two columns on each table before Merge.

9. Fuzzy match almost-same names (Rahul / Rahul P).

Hint: Merge dialog → Fuzzy matching (Microsoft 365). Start with a small sample.

10. Keep the merge as a separate query named OrdersWithCity.

Hint: Use Merge Queries as New, then rename in the Queries pane.

11. Add a custom column Amount£ = Amount₹/105 for a UK report.

Hint: Add Column → Custom Column after the merge.

12. Document the join kind in a step note for your team.

Hint: Right-click the Merge step → Properties → Description.

Loading practice tasks...

  1. Rows in the import (Easy): How many rows are in the Order ID column?
  2. Clean one customer name (Easy): Remove the extra spaces from the first Customer name.
  3. Fix the case of a city (Easy): Show the first City in normal case, like "Pune".
  4. Total quantity (Easy): Add up the Qty column.
  5. How many spaces were extra? (Medium): How many extra spaces does the first Customer name have?
  6. Duplicate order check (Medium): How many times does Order ID "ORD-502" appear?
  7. Orders from one city, any case (Medium): How many rows have City "Toronto", in any case?
  8. Amount by channel (Medium): Add up the Amount column for rows where Channel is "App".
  9. Average order amount (Medium): Find the average of the Amount column, rounded to 0 decimals.
  10. Rows after Remove Duplicates (Hard): How many rows are left after the extra copies of "ORD-502" are removed?
  11. Biggest store order (Hard): What is the largest Amount where Channel is "Store"?
  12. Price per unit (Hard): For the first row, divide Amount by Qty.

Quick revision cards

Three standalone cards. Each one explains the idea with its own example. Scan the QR to open this lesson.

Revision card 1: What is Merge Queries?
Card 1: What is Merge Queries? · Download PNG
Revision card 2: Left Outer vs Inner
Card 2: Left Outer vs Inner · Download PNG
Revision card 3: Expand after Merge
Card 3: Expand after Merge · Download PNG