Power Query course · Lesson 5 of 17

Splitting and merging columns

Split columns by delimiter, number of characters, positions or character transitions, split into rows, and merge columns with a separator.

Beginner 14 min read

Source systems love to pack several facts into one column (Lopez, Maria, SKU-2231-RED-L, Athens 10558) or to scatter one fact over several columns (Street, No, City, Postcode). Power Query's Split Column and Merge Columns commands fix both problems. They are the repeatable, more flexible versions of Excel's Text to Columns wizard and of formulas such as TEXTSPLIT, TEXTJOIN and CONCAT.

Split by delimiter

A delimiter is a character that separates the parts, such as a comma, a hyphen or a space. Select the column and choose Home › Split Column › By Delimiter (also on Transform › Split Column and on the right-click menu). The dialog asks:

  • Select or enter delimiter: Colon, Comma, Equals Sign, Semicolon, Space, Tab, or --Custom-- for any text, even several characters like / .
  • Split at: Left-most delimiter (two parts, split at the first occurrence), Right-most delimiter (two parts, split at the last occurrence) or Each occurrence of the delimiter (as many parts as needed).
  • Advanced options: split into Columns or Rows, the Number of columns to split into, the Quote Character (so a comma inside quotes is not a split point) and Split using special characters for tabs and line breaks.
ABC
1EmployeeDepartmentLocation
2Lopez, MariaFinanceMadrid / ES
3Becker, TomSalesHamburg / DE
4Tanaka, AikoITLisbon / PT
5Van der Berg, JanSalesUtrecht / NL

Before: an HR list with last and first name in one column and city plus country code in another.

  1. Select Employee › Split Column › By Delimiter › --Custom-- , (comma and space) › Left-most delimiter › OK.
  2. Rename the new columns Employee.1 and Employee.2 to Last name and First name by double-clicking the headers.
  3. Select Location › Split Column › By Delimiter › --Custom-- / › Each occurrence of the delimiter › OK, and rename to City and Country.
ABCDE
1Last nameFirst nameDepartmentCityCountry
2LopezMariaFinanceMadridES
3BeckerTomSalesHamburgDE
4TanakaAikoITLisbonPT
5Van der BergJanSalesUtrechtNL

After: one fact per column. Splitting at the left-most comma keeps 'Van der Berg' together because the spaces inside it are not the delimiter.

Power Query M
= Table.SplitColumn(Source, "Employee", Splitter.SplitTextByEachDelimiter({", "}, QuoteStyle.Csv, false), {"Last name", "First name"})
The step for Left-most delimiter. The last argument of SplitTextByEachDelimiter is false for left-most, true for right-most.
Tip. You can give the new columns their final names directly in the step, as above, by editing the list {"Employee.1", "Employee.2"} in the formula bar. That saves a separate Renamed Columns step.
Watch out. With Each occurrence of the delimiter, Power Query counts the parts in the preview rows and writes that number into the step. If a later file has a value with more parts, the extra parts are dropped without warning. When the number of parts varies, split into rows instead, or check the column count in the step.

Split into rows

Sometimes a cell holds a list: an employee's skills Excel, SQL, Python, or an order's coupon codes. To analyse the items you want one row per item. In the By Delimiter dialog open Advanced options and choose Split into Rows.

AB
1EmployeeSkills
2Maria LopezExcel, SQL
3Tom BeckerNegotiation
4Aiko TanakaPython, SQL, Power BI

Before: several skills in one cell.

AB
1EmployeeSkills
2Maria LopezExcel
3Maria LopezSQL
4Tom BeckerNegotiation
5Aiko TanakaPython
6Aiko TanakaSQL
7Aiko TanakaPower BI

After: Split into Rows with delimiter ', '. Now a PivotTable can count how many people know SQL.

Power Query M
= Table.ExpandListColumn(Table.TransformColumns(Source, {{"Skills", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv)}}), "Skills")
Splitting turns each cell into a list; ExpandListColumn gives each list item its own row and copies the other columns.

Split by number of characters and by positions

Fixed-width exports from older systems put each field at a fixed place in the line. Two commands handle them:

  • Split Column › By Number of Characters: for example 2 characters Repeatedly, or Once, as far left as possible. Splitting a postcode-plus-city text like 10558Athens once after 5 characters gives 10558 and Athens.
  • Split Column › By Positions: a comma-separated list of starting positions, counted from 0. 0, 8, 14 splits 20260315SO5512Shipped into 20260315, SO5512 and Shipped.

Split by character transition

Four more options split where the kind of character changes: By Lowercase to Uppercase, By Uppercase to Lowercase, By Digit to Non-Digit and By Non-Digit to Digit. BoxSize40 split by non-digit to digit gives BoxSize and 40; MariaLopez split by lowercase to uppercase gives Maria and Lopez. They are rarely needed, but when a product code mixes letters and numbers they save a custom formula.

Merging columns

Merging is the opposite: several columns become one text column. Select the columns in the order you want them joined (click the first, Ctrl+click [Cmd+click on Mac] the others), then choose:

  • Transform › Merge Columns to replace the selected columns with the merged one, or
  • Add Column › Merge Columns to keep them and add the merged column.

Pick a Separator (Colon, Comma, Equals Sign, Semicolon, Space, Tab or Custom) and type a New column name. Numbers and dates are converted to text automatically.

ABCD
1RegionStoreYearMonth
2EUATH0120263
3EULIS0220263
4NABOS0120263

Before: the parts of a report key in separate columns.

ABC
1Store keyYearMonth
2EU-ATH0120263
3EU-LIS0220263
4NA-BOS0120263

After: Region and Store merged with the custom separator '-' into Store key, ready to match a store master list.

Power Query M
= Table.CombineColumns(Source, {"Region", "Store"}, Combiner.CombineTextByDelimiter("-", QuoteStyle.None), "Store key")
Transform › Merge Columns writes Table.CombineColumns. Add Column › Merge Columns writes Table.AddColumn with Text.Combine instead.
Watch out. If one of the merged columns contains null, Merge Columns skips it and you may get a key like EU- with a trailing separator, or no separator at all. Replace nulls with a placeholder first (Transform › Replace Values, value to find null) if every key must have the same structure.

Merging with a custom formula

For more control, for example to build an invoice number like INV-2026-0007 with zero padding, use Add Column › Custom Column and a formula:

Power Query M
= Table.AddColumn(#"Changed Type", "Invoice no", each "INV-" & Text.From([Year]) & "-" & Text.PadStart(Text.From([Seq]), 4, "0"), type text)
& joins text in M just as in Excel, but numbers must be converted with Text.From first; Text.PadStart adds leading zeros.

Unlike Excel, M does not convert numbers to text automatically when you use &: "INV-" & 2026 is an error. Text.From is the fix. Custom columns are covered fully in Custom and conditional columns.

Choosing the right tool

SituationCommand
Last, First in one columnSplit By Delimiter, Left-most
Path or category tree, need the last partSplit By Delimiter, Right-most, or Extract › Text After Delimiter
List of items in one cellSplit By Delimiter, Advanced, into Rows
Fixed-width text fileSplit By Positions
Build a key from several fieldsMerge Columns, or Custom Column with Text.From

Check yourself

1. You need to split 'Van der Berg, Jan' into last and first name. Which setting is right?

2. How do you get one row per skill from 'Excel, SQL'?

3. Which tab keeps the original columns when merging?

4. In M, what does "INV-" & 2026 return?

5. Split By Positions uses positions counted from…