Ravindra BagaleCourses & study guides Track your progress

Excel → Power BI Bridge

Bridge 5. Power Query in Excel and Power BI

Friends,

Friends, power Query is the shared kitchen. Excel and Desktop cook with the same M. Learn once; use twice.

About this data: Practice names (Priya, Amit, Emma, Omar, Sofia, Ananya, Chen Wei, Neha), cities and ₹ $ £ € amounts are fictional. Safe for class. Workbook includes an About this data sheet.

At deploy, files go to s3://ravindrabagale-cards/excel/bridge/ .

What you will learn

  • See Excel PQ and Desktop PQ as one engine.
  • Trim / type / unpivot before load.
  • Know Close & Load vs Close & Apply.
  • Use append/merge without destroying keys.

A short story

Emma’s Manchester file has wide Jan/Feb/Mar columns. Neha’s names have extra spaces. Same Unpivot and Trim steps work in Excel PQ and in Desktop.

Ravindra Bagale’s Tip

Fix messy columns in Power Query, not with 40 helper columns you forget to refresh.

1. Same engine, two doors

Friends,

If you can Unpivot in Excel PQ, you can Unpivot in Desktop.

Why: Get Data in Excel and Desktop open PQ.

What: Home → Get Data / Launch Power Query Editor.

How:

  1. Open the workbook in Excel PQ or Desktop.
  2. View the Applied Steps pane.
  3. Rename the query to Sales_Clean.
  4. Know that M is behind the clicks.
ExcelPower BI / DAXResultMeaning
Excel
Data → Get Data
Power BI
Home → Get Data
Editor Priya opens the same steps in either tool.

2. Trim and clean text

Friends,

Trim before you merge on Name — better: merge on keys, not names.

Why: Spaces break joins later.

What: Transform → Format → Trim / Clean.

How:

  1. Select Name column → Trim.
  2. Replace double spaces if needed.
  3. Set types after cleaning.
  4. Close & Apply / Load.
ExcelPower BI / DAXResultMeaning
Excel PQ
Trim on Name
Desktop PQ
Trim on Name
Clean " Priya Sharma" becomes Priya Sharma.

3. Wide months → tall facts

Friends,

Tall facts + a Month column beat 12 month columns forever.

Why: Jan/Feb/Mar columns are analysis poison long-term.

What: Select month columns → Unpivot Columns.

How:

  1. On Wide_Months, select Jan,Feb,Mar.
  2. Unpivot Columns → Attribute=Month, Value=Amount.
  3. Rename Attribute to Month.
  4. Load tall table for Pivot/Matrix.
ExcelPower BI / DAXResultMeaning
Excel sheet
Wide months
Power Query
Unpivot → tall
Tall Amit’s Nashik months become rows.

4. Append monthly files

Friends,

Append needs matching columns. Merge needs matching keys.

Why: Stack same-shaped tables.

What: Append Queries.

How:

  1. Keep identical column names.
  2. Append April under March.
  3. Add a SourceFile column if helpful.
  4. Avoid appending different schemas blindly.
ExcelPower BI / DAXResultMeaning
Excel
Copy-paste under (risky)
Power Query
Append Queries
Stacked Omar stacks Dubai fee months.

5. Merge ≈ controlled VLOOKUP

Friends,

Keys beat fuzzy name matches for class and for production.

Why: Bring ProductName onto sales with ProductID.

What: Merge Queries → Left Outer on ProductID.

How:

  1. Sales Left Outer Dim_Product.
  2. Expand ProductName only.
  3. Do not expand everything “just in case”.
  4. Validate with a few known IDs.
ExcelPower BI / DAXResultMeaning
Excel
VLOOKUP/XLOOKUP
Power Query
Merge on ProductID
Name on fact Chen Wei sees USB cable names.

6. Types before Apply

Friends,

Type once in PQ; stop re-fighting charts later.

Why: Same lesson as tables chapter — reinforce.

What: Set Decimal / Date / Text in PQ.

How:

  1. Amount → Decimal.
  2. Date → Date.
  3. ID codes → Text.
  4. Apply and spot-check Data view.
ExcelPower BI / DAXResultMeaning
Excel format
Cosmetic often
PQ data type
Real type for model
Typed Sofia’s € amounts sum.

7. Close & Load vs Close & Apply

Friends,

Staging queries clean; only facts/dims load.

Why: Excel loads to sheet/model; Desktop to model.

What: Know where the data landed.

How:

  1. Excel: Close & Load to Table on sheet (or Data Model).
  2. Desktop: Close & Apply to model.
  3. Disable load for staging.
  4. Refresh later from the same query.
ExcelPower BI / DAXResultMeaning
Excel
Close & Load
Power BI
Close & Apply
Landed Ananya finds Sales_Clean in the right place.

8. Refresh the query, not the myth

Friends,

The recipe (steps) matters more than one heroic paste.

Why: Change source rows; refresh steps replay.

What: Data → Refresh / Home → Refresh.

How:

  1. Add a new sale row in source.
  2. Refresh the query.
  3. Confirm new row appears.
  4. Teach that steps are the recipe.
ExcelPower BI / DAXResultMeaning
Excel
Refresh All
Desktop
Refresh
Updated Neha’s new Kolhapur line appears.

Practice tasks (12)

Use bridge-pq-practice.xlsx. LibreOffice-safe: prefer SUMIF / VLOOKUP / IF — avoid XLOOKUP, TEXTJOIN, TEXTSPLIT.

  1. Read About. Open Wide_Months.
    Hint

    See Jan/Feb/Mar.

  2. In Excel (or describe steps): Unpivot Jan–Mar.
    Hint

    Attribute→Month.

  3. On Dirty_Names, write =TRIM(A2) helper (LibreOffice OK).
    Hint

    Preview clean names.

  4. List Applied Steps you would keep for Sales_Clean.
    Hint

    Notes.

  5. Write Append vs Merge in one line each.
    Hint

    Stack vs key join.

  6. SUM of Jan column on Wide_Months with SUM.
    Hint

    Before unpivot.

  7. Explain why codes stay Text after PQ.
    Hint

    Leading zeros.

  8. Disable-load purpose in one sentence.
    Hint

    Staging.

  9. Map Close & Load vs Close & Apply.
    Hint

    Excel vs Desktop.

  10. Propose a SourceMonth column after append.
    Hint

    Which file/month.

  11. COUNTIF cities on Dirty_Names.
    Hint

    Quality check.

  12. Write the refresh click path you will teach.
    Hint

    Refresh All / Refresh.

Quick quiz

Q1. Excel PQ and Desktop PQ share…

Q2. Unpivot turns wide months into…

Q3. Trim mainly fixes…

Q4. Merge Queries is closest to…

Q5. Append Queries needs…

Q6. Close & Apply in Desktop loads to…

Q7. Staging query tip:

Q8. After source rows change, you…

Loading practice tasks...

  1. Rows in the fact table (Easy): How many orders are in the Sales table?
  2. Total amount (Easy): Add up the Amount column of Sales.
  3. Total quantity (Easy): Add up the Qty column of Sales.
  4. Products in the dimension (Easy): How many products are in the Products table?
  5. Products actually sold (Medium): How many of the 5 Product IDs (P01 to P05) appear at least once in Sales?
  6. Amount for one city (Medium): Add up Amount where City is "London".
  7. Product name through the relationship (Medium): What is the Product name for Product ID "P03"?
  8. Sales of one product (Medium): Add up Amount where Product ID is "P03".
  9. Average order amount (Medium): Find the average Amount, rounded to 0 decimals.
  10. Category of the first order (Hard): Find the Category of the product in the first order.
  11. Biggest order in London (Hard): What is the largest Amount where City is "London"?
  12. Share of P03 (Hard): What share of the total Amount comes from Product ID "P03"? Round to 3 decimals.

Quick revision cards (3)

Approved Excel card style: standalone, no tip/photo section, QR to this lesson.

Revision card: Card 1 — Same M engine
Card 1 — Same M engine
Revision card: Card 2 — Unpivot
Card 2 — Unpivot
Revision card: Card 3 — Load vs Apply
Card 3 — Load vs Apply