Merging & Appending Queries: Joins vs Unions
Overview & Learning Objectives
Raw data is almost never clean. Header rows often get trapped in row 1, numbers masquerade as text, and composite keys like order IDs contain multiple data attributes glued together. Cleaning these defects in Power Query ensures accurate aggregations and seamless visual filtering.
- Promote first rows to headers and demote headers when necessary.
- Assign explicit data types (Decimal, Integer, Text, Date) to prevent aggregation bugs.
- Split columns by delimiters (comma, hyphen, space) and replace null/error values.
Industry Standard
Standard: Enterprise modeling protocols at Amazon dictate that every numerical measure column must be explicitly assigned a Decimal or Whole Number type in Power Query before reaching the canvas.
Real-World Example: Spice Delight Cloud Kitchen
Spice Delight extracts order receipts where order codes contain order number, store city, and status combined as "ORD1049-MUM-DELIVERED".
| Raw Order Token | Promoted Header | Split Part 1 (Order ID) | Split Part 2 (City Code) | Split Part 3 (Status) |
|---|---|---|---|---|
| ORD1049-MUM-DELIVERED | OrderToken | ORD1049 | MUM | DELIVERED |
| ORD1050-DEL-CANCELLED | OrderToken | ORD1050 | DEL | CANCELLED |
| ORD1051-BLR-DELIVERED | OrderToken | ORD1051 | BLR | DELIVERED |
Syntax & Core Workflow
Transform Tab -> Split Column -> By Delimiter -> Select "-" -> Split at Each Occurrence of Delimiter
Parameters Breakdown
Use First Row as Headers: Promotes row 1 of the raw data grid into the official table column header names.Data Type Assignment: Sets whether values are parsed as Numbers (123), Text (ABC), Dates, or Booleans (TRUE/FALSE).Split Column by Delimiter: Divides a single string column into multiple distinct columns based on a separator character.Replace Values: Finds targeted substrings or nulls and replaces them with a fallback default value.
Sample Walkthrough (Q&A)
Question: What happens if a column of product prices has data type "Text" (ABC) in Power BI?
Formula / Action: Select column -> Click data type icon at top left of header -> Change to "Fixed Decimal Number" ($).
Result: The column becomes aggregatable with SUM, AVERAGE, and numeric slicers.
Explanation: Columns typed as Text cannot be summed or averaged. Power BI will only allow "First", "Last", or "Count" operations on text fields.
Common Mistakes & Limitations
- Leaving numerical values as "Any" or "Text" data type, causing DAX formulas like SUM([Price]) to fail or behave unpredictably.
- Replacing errors blindly with zero without discovering why rows contained errors (e.g. division by zero, string conversion failure).
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Open Replace Values dialogue | Alt -> H -> R -> V | Option -> H -> R -> V |
| Promote First Row as Headers | Alt -> H -> H | Option -> H -> H |
Pro Tips & Modern Alternatives
- Use "Split by Number of Characters" or "Split by Positions" when parsing standardized fixed-width employee codes or bank transaction identifiers.
- Right-click column header -> Transform -> Clean and Trim to strip non-printable characters and accidental trailing spaces.