Skip to content

Splitting columns

A column often holds more than one value that needs separating, such as a full name that should become a first name and a last name. Split Column on the Transform tab, or on the column’s right-click menu, does this, and By Delimiter splits the text wherever a chosen character appears.

The split can produce new columns or new rows. Splitting into rows is the less obvious option, but it is often the one needed, because it pairs each separate value with the rest of the row it came from.

In the source table on the left, each product lists all of its colours in a single cell, separated by commas. The aim is the table on the right, which has one row for each product and colour, so the products can then be counted by colour:

Two tables side by side: on the left, products and cities with comma-separated colours such as Red, Black, White in one cell; on the right, the same data with one row per product and colour

Loaded into Power Query, the data looks like this:

The table in the Power Query Editor with Product, City and Color columns, where each Color cell holds up to three colours

Right-click the Color column, choose Split Column and then By Delimiter:

The right-click menu on the Color column, with Split Column open and By Delimiter at the top of the submenu

Choose Comma as the delimiter, and split at each occurrence of the delimiter:

The Split Column by Delimiter dialog with Comma selected and Each occurrence of the delimiter chosen, and the Advanced options section closed

The colours are now spread across new columns named Color.1, Color.2 and Color.3, with nulls where a product has fewer than three colours:

The table with the colours split across Color.1, Color.2 and Color.3, and null in the empty cells

This is not the shape that was wanted, because a count by colour would have to look across three columns.

Repeat the split, but this time open Advanced options in the dialog and choose to split into Rows:

The Split Column by Delimiter dialog with Advanced options open and Split into set to Rows

The result has one row for each colour, with the product and city repeated on each:

The table with 29 rows, one for each product and colour, such as Tesla in Los Angeles appearing three times with Red, Black and White

The technique on this page follows one in Gil Raviv’s Collect, Combine, and Transform Data Using Power Query in Excel and Power BI (Microsoft Press).