Power BI Course
Splitting and Merging Columns
Real-world data constantly arrives with values crammed into a single column that should be separate, or values split across multiple columns that should be combined. A full name in one field, a city and postcode jammed together, a date and time sharing a column, a product code that encodes both category and SKU. This lesson covers every technique for splitting columns apart and merging them back together — including the shortcut that writes the transformation for you.
The Working Dataset
All examples in this lesson use the same source table — a typical export that packs too much into individual columns.
| FullName | AddressLine | OrderDateTime | ProductCode | Revenue |
|---|---|---|---|---|
| Alice Brown | 14 Oak St, Austin, TX 78701 | 2024-01-05 09:42:00 | ELEC-1042 | 1,200 |
| Bob Singh | 7 Maple Ave, Denver, CO 80203 | 2024-01-18 14:15:00 | FURN-2087 | 850 |
| Carol Lee | 33 Pine Rd, Seattle, WA 98101 | 2024-02-03 08:00:00 | ACCS-3301 | 430 |
| David Kim | 92 River Blvd, Miami, FL 33101 | 2024-02-14 17:30:00 | ELEC-0955 | 95 |
Split Column — All Methods
Split Column is accessed from the Transform tab (replaces the original column) or the Add Column tab (creates new columns alongside the original). Always use Add Column when you want to keep the source value intact. The split dialog offers seven different splitting strategies.
| Split method | How it works — when to use it |
|---|---|
| By Delimiter | Splits at every occurrence of a character (comma, space, dash, pipe). Specify whether to split at each occurrence, the leftmost, or the rightmost. The most commonly used split method — covers the majority of real-world cases. |
| By Number of Characters | Splits at a fixed character position. Use when the value has a fixed-width format — e.g. a product code where the first 4 characters are always the category ("ELEC") and the rest is the SKU number. |
| By Positions | Splits at multiple specific character positions in one step. Enter a comma-separated list of positions: 0, 4, 8 splits a 12-character code into three 4-character segments. |
| By Lowercase to Uppercase | Splits wherever a lowercase letter is immediately followed by an uppercase letter. Use for CamelCase strings — "firstNameLastName" splits into "first Name" + "Last Name". |
| By Uppercase to Lowercase | Splits wherever an uppercase letter is immediately followed by a lowercase letter — useful for strings like "SalesManager" → "Sales" + "Manager". |
| By Digit to Non-Digit | Splits where a number is followed by a letter or symbol — e.g. "123ABC" → "123" + "ABC". Useful for mixed alphanumeric codes where the numeric and text portions need to be separated. |
| By Non-Digit to Digit | The reverse — splits where a letter or symbol is followed by a number. "ELEC1042" → "ELEC" + "1042". |
Example 1 — Split FullName into FirstName and LastName
The FullName column contains first and last name separated by a single space. Split by delimiter (space), at each occurrence, produces two new columns.
| FirstName | LastName |
|---|---|
| Alice | Brown |
| Bob | Singh |
| Carol | Lee |
| David | Kim |
Example 2 — Extract Category from ProductCode
The ProductCode column stores values like "ELEC-1042" where the prefix before the dash is the product category. Two approaches work here — Split by Delimiter (dash), or Extract Text Before Delimiter. Use Extract when you only need one part and want to leave the original column untouched.
Option A — Split Column by Delimiter (dash)
Select ProductCode column
Transform tab → Split Column → By Delimiter
Delimiter: Custom → enter: -
Split at: Left-most delimiter only
Result: ProductCode.1 (category) and ProductCode.2 (SKU number)
Rename ProductCode.1 → Category
Rename ProductCode.2 → SKU
Option B — Extract (keeps original column intact)
Select ProductCode column
Add Column tab → Extract → Text Before Delimiter
Delimiter: -
Result: a NEW column "Text Before Delimiter" alongside ProductCode
Rename → Category
Original ProductCode column is unchanged
M code for Option B:
= Table.AddColumn(
#"Changed Type",
"Category",
each Text.BeforeDelimiter([ProductCode], "-"),
type text
)
| ProductCode | Revenue | Category (new) |
|---|---|---|
| ELEC-1042 | 1,200 | ELEC |
| FURN-2087 | 850 | FURN |
| ACCS-3301 | 430 | ACCS |
| ELEC-0955 | 95 | ELEC |
Example 3 — Split OrderDateTime into Date and Time
The OrderDateTime column combines a date and time in a single value — "2024-01-05 09:42:00". For most reports you need these as separate columns: a Date column to connect to a Calendar table, and a Time column if time-of-day analysis is needed.
Extract — Getting Part of a Text Value
The Extract menu (Add Column tab → Extract or Transform tab → Extract) provides targeted text extraction without a full split. Use it when you need only one piece of a value and want to avoid creating unnecessary columns.
| Extract option | What it returns — example |
|---|---|
| First Characters | First N characters from the left. "ELEC-1042" → First 4 → "ELEC" |
| Last Characters | Last N characters from the right. "TX 78701" → Last 5 → "78701" (the zip code) |
| Range | Characters from position X for N characters. Position 5, length 4 on "2024-01-05" → "01-0" — useful for fixed-width codes with known segment positions. |
| Text Before Delimiter | Everything to the left of a delimiter. "Austin, TX 78701" → Before "," → "Austin" |
| Text After Delimiter | Everything to the right of a delimiter. "ELEC-1042" → After "-" → "1042" |
| Text Between Delimiters | Everything between two delimiters. "[Austin]" → Between "[" and "]" → "Austin". Useful for values wrapped in brackets, parentheses, or quotes. |
Merging Columns
Merging combines two or more columns into a single column, joining the values with a separator you define. Common uses include rebuilding a full address from parts, creating a composite key for relationships, or combining a year and month number into a sortable period label.
Merging with Custom Column — More Control
For merges that need conditional logic, different separators between different column pairs, or mixed text and numbers, use Add Column → Custom Column instead of Merge Columns. The M concatenation operator is & and works on text columns only — numbers must be wrapped in Text.From().
// Example 1 — Full name with a space
// Add Column → Custom Column
= [FirstName] & " " & [LastName]
// Result: "Alice Brown"
// Example 2 — Composite key from two text columns
= [CustomerID] & "-" & [OrderID]
// Result: "C101-1001" — useful as a unique row key
// Example 3 — Merging a number with text
// Numbers must be converted to text first using Text.From()
= [Category] & "-" & Text.From([SKU])
// Result: "ELEC-1042"
// Example 4 — Conditional merge
// Add a prefix only when a condition is met
= if [Status] = "Urgent" then "!! " & [OrderID] else [OrderID]
// Result: "!! 1001" for urgent orders, "1002" for normal
// Example 5 — YearMonth period label for sorting
= Text.From(Date.Year([OrderDate])) & "-"
& Text.PadStart(Text.From(Date.Month([OrderDate])), 2, "0")
// Result: "2024-01", "2024-02" — sorts correctly as text
Column from Examples — The Shortcut
Column from Examples is the fastest way to extract or combine text when you know what the output should look like but do not want to write M code. You type example output values and Power Query reverse-engineers the transformation formula automatically.
| AddressLine (source) | Column1 — type examples here ↓ |
|---|---|
| 14 Oak St, Austin, TX 78701 |
Austin
← you type this
|
| 7 Maple Ave, Denver, CO 80203 | Denver ← Power Query fills in automatically |
| 33 Pine Rd, Seattle, WA 98101 | Seattle |
| 92 River Blvd, Miami, FL 33101 | Miami |
Teacher's Note: The single most common splitting mistake is forgetting to use Add Column instead of Transform when you want to keep the original. If you split FullName from the Transform tab, the original FullName column is gone — replaced by FirstName and LastName. If the source data ever needs the combined name for matching or display, you have lost it. The habit to build: when in doubt, use Add Column to split or extract, then decide afterwards if the original column is still needed and delete it deliberately.
Practice
Practice 1 of 3
You need to extract only the city name from an AddressLine column without writing any M code. You know what the city values should look like. The fastest approach is to use Add Column → Column from ___.
Practice 2 of 3
You want to combine a Year column (number) and a Month column (number) into a text label like "2024-03". Because Month is a number, you must wrap it in ___ before using the & operator to concatenate it with other text.
Practice 3 of 3
You split a ProductCode column using the Transform tab → Split Column → By Delimiter. After the split you notice the original ProductCode column is gone. This happened because using the Transform tab ___ the original column rather than creating a new one alongside it.
Lesson Quiz
Quiz 1 of 3
A CustomerName column contains values like "Alice Brown", "Mary Jo Smith", and "Dr. James Long". You split by space at each occurrence. What problem do you get, and what is the correct fix?
Quiz 2 of 3
You need to create a composite key column by joining CustomerID and OrderID with a hyphen — for example "C101-1001". CustomerID is text but OrderID is a whole number. What Custom Column formula works correctly?
Quiz 3 of 3
You want to create a YearMonth column like "2024-01", "2024-02" for use as a sort key in a line chart. A colleague suggests just concatenating Year and Month as "2024-1", "2024-2". Why is this a problem and how do you fix it?
Next up — Lesson 22 covers Appending and Merging Queries — how to stack tables vertically with Append and join tables horizontally with Merge, including all six join types and the pattern for combining monthly files automatically.