Power BI Lesson 21 – Split & Merge Columns | Dataplexa
Power Query · Lesson 21

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.

Source table — column problems highlighted
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
🟡 FullName — needs splitting into FirstName + LastName  |  🔴 AddressLine — city, state, zip all in one  |  🔵 OrderDateTime — date and time together  |  🟣 ProductCode — category prefix encoded in value

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.

Split Column by Delimiter dialog
Select or enter delimiter
Space
Split at
Result: FullName.1 and FullName.2 — rename to FirstName and LastName
After split + rename
FirstNameLastName
AliceBrown
BobSingh
CarolLee
DavidKim
Watch out: If any FullName contains three words — "Mary Jo Smith" — splitting at each space produces three columns, not two. The third name lands in FullName.3 and the row for "Bob Singh" has a null in FullName.3. Use "Left-most delimiter only" to always get exactly two columns: everything before the first space, and everything after.

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
    )
Option B result — Category extracted, ProductCode preserved
ProductCode Revenue Category (new)
ELEC-10421,200ELEC
FURN-2087850FURN
ACCS-3301430ACCS
ELEC-095595ELEC
ProductCode intact · Category extracted as a separate column · ready to use as a slicer or relationship key

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.

Method 1 — Change the type
If you only need the date portion, simply change the column type from Date/Time to Date. Power Query truncates the time component and keeps the date. Fast, one-step, no new columns.
Best when: you only ever need the date, not the time
Method 2 — Duplicate + type change
Duplicate the OrderDateTime column → change one copy's type to Date (rename OrderDate) → change the other copy's type to Time (rename OrderTime). Both parts are preserved.
Best when: you need both date and time as separate usable columns
Split by delimiter (space) also works — "2024-01-05 09:42:00" split by space gives two columns. But changing the type of a duplicate is cleaner because Power Query handles the date/time parsing automatically, producing proper typed Date and Time values rather than text strings that need another type change step.

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.

Merge Columns dialog
Selected columns (in order)
FirstName1st
LastName2nd
Hold Ctrl to select multiple columns before opening Merge
Separator
Space
Options: None, Colon, Comma, Semicolon, Slash, Space, Tab, Custom
New column name
FullName
Preview: Alice Brown
Important: The Transform tab's Merge Columns replaces the selected columns with the merged result — the originals are deleted. The Add Column tab's Merge Columns creates the merged column alongside the originals. Use Add Column when you need to keep the individual parts for filtering or relationships.

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
Custom Column results — all five examples
Example 1 — FullName
"Alice Brown", "Bob Singh", "Carol Lee", "David Kim"
Example 2 — CompositeKey
"C101-1001", "C102-1002", "C103-1003", "C101-1004"
Example 3 — Category+SKU
"ELEC-1042", "FURN-2087", "ACCS-3301", "ELEC-0955"
Example 4 — Urgent flag
"1001", "!! 1002", "1003", "1004" (order 1002 flagged urgent)
Example 5 — YearMonth
"2024-01", "2024-01", "2024-02", "2024-02"
Text.PadStart pads single-digit months to two digits — ensures "2024-02" sorts before "2024-10" as text. Without it, "2024-2" would sort after "2024-10".

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.

Column from Examples — extracting city from AddressLine
Add Column tab → Column from Examples → From Selection (select the AddressLine column first)
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
Formula inferred: Text.BetweenDelimiters([AddressLine], ", ", ", ") — Power Query figured out you want the text between the first and second comma-space

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.