Sub topic 7
Splitting and Merging Columns
This chapter assumes you can open the Power Query Editor, read the Applied Steps pane, and set data types. Splitting and merging columns are two of the most common reshaping steps after text cleanup.
When to split and when to merge
Source data often packs several values into one column, such as Smith, Anna or 2025-03-EU. Splitting separates those values so you can filter, sort, and group on each part. Merging does the reverse. It builds one key or label from several columns, for example a full name or a lookup key for a later merge of queries.
Splitting a column
Select the column, then choose Home > Split Column (or Transform > Split Column). The main options are:
- By Delimiter: split at a character such as a comma, space, or custom text. You choose to split at the left-most, right-most, or every occurrence.
- By Number of Characters: split at fixed positions, useful for codes of constant length.
- By Positions, Lowercase to Uppercase, Digit to Non-Digit: for less regular patterns.
When you split at every delimiter, Power Query creates columns named Name.1, Name.2, and so on. It decides how many columns to create by looking at the data it previews. If a later refresh brings a row with more parts, the extra parts may be ignored or cause an unexpected column count. To be safe, split at the left-most or right-most delimiter when you know you need only two parts. You can also choose Advanced Options > Split into Rows when each cell holds a list of values.
Always trim the text and set a type before splitting. A stray space in Anna will otherwise stay in the new column.
Merging columns
Select two or more columns in the order you want them joined, then choose Transform > Merge Columns. You pick a separator and a name for the new column. The original columns are removed by default. If you need them too, use Add Column > Custom Column instead, which keeps the originals.
Merge Columns works on text. If you merge a number or date column, Power Query converts it to text first.
Worked example
This query splits FullName (stored as Last, First) into two columns, then builds a Key column from Region and Product.
let
Source = Excel.CurrentWorkbook(){[Name="Contacts"]}[Content],
Split = Table.SplitColumn(
Source,
"FullName",
Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv),
{"LastName", "FirstName"}
),
Typed = Table.TransformColumnTypes(Split, {{"LastName", type text}, {"FirstName", type text}}),
Merged = Table.CombineColumns(
Typed,
{"Region", "Product"},
Combiner.CombineTextByDelimiter("-", QuoteStyle.None),
"Key"
)
in
MergedThe two step names, Split and Merged, are what you see in Applied Steps. The {"LastName", "FirstName"} list fixes the new column names and count, so a row with an extra comma will not add a column.
Common errors
- Splitting before cleaning leaves extra spaces or non-printing characters in the results.
- Merging a column that contains
nullgives a null result in some cases. Replace nulls first, or use a custom column. - Renaming a source column breaks a later split step, because the step refers to the old name.
Exercise
A column Code holds values like EU-2025-A. You want only the text before the first hyphen in a column named Area. Which split option and occurrence do you choose?
Show answer
Use Split Column By Delimiter with a hyphen, split at the left-most delimiter, then keep the first resulting column and rename it Area. Delete or ignore the second column, which holds 2025-A.