Stop 04 · Power Query TransformationsTopics · 6/11

Splitting and Merging Columns

Part of the Power BI Roadmap

In short

Data often packs two facts into one column, like 'Pune, Maharashtra', or spreads one fact across two, like first and last name. Splitting and merging puts each fact in its proper place.

Split Column breaks a column by a delimiter or position, like splitting 'Pune, Maharashtra', and Merge Columns joins several columns into one.

The jaadu cuts a long roll of patterned cloth along a chalk line with big scissors, while two small pieces lie stitched together nearby.

Think of it like this

Cutting and stitching cloth

A tailor cuts one long length of fabric into a kurta piece and a dupatta piece along a marked line, and stitches two short pieces into one sleeve. Split Column is the cut along a marker, and Merge Columns is the stitch.

Watch it happen

From one Location column to City and State

Location
Split by ', '
City | State
Trim

1/4Location holds values like 'Pune, Maharashtra' and 'Kochi,Kerala'.

The big ideas

What you need to know

Split by delimiter

Choose comma, space, dash or a custom character, and split at the left-most, right-most or every occurrence.

Split by position

Useful for fixed codes, like taking the first two characters of MH12AB3456 as the state code.

Merge with a separator

Select columns in order, then Merge Columns with a separator such as a space or a hyphen.

Add Column versions

The Add Column tab has Merge and Extract options that keep the original columns intact.

See it in code

Walk through the code

m
1let2    Source = Customers,3    SplitLocation = Table.SplitColumn(4        Source,5        "Location",6        Splitter.SplitTextByEachDelimiter({","}, QuoteStyle.Csv, false),7        {"City", "State"}8    ),9    Trimmed = Table.TransformColumns(10        SplitLocation,11        {{"City", Text.Trim, type text}, {"State", Text.Trim, type text}}12    ),13    FullName = Table.CombineColumns(14        Trimmed,15        {"FirstName", "LastName"},16        Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),17        "Customer Name"18    )19in20    FullName

1/3Split at the left-most comma only. The false argument means start from the left.

Split Location at the first comma, trim spaces, and merge first and last names into one column.

Save yourself the pain

Common mistakes

Oops

Splitting at every comma when some addresses contain extra commas.

Do this instead

Split at the left-most or right-most delimiter, or extract text before or after a delimiter.

Oops

Forgetting to trim after a split, then wondering why 'Kerala' and ' Kerala' appear as two states.

Do this instead

Add Format, Trim straight after the split.

Your mission

Untangle a customer list

~20 min

Quick check

You split 'Pune, Maharashtra' by comma and the State column shows ' Maharashtra'. What fixes it?

Go deeper

  1. 1Split a full name into first and last name.
  2. 2Merge year and month columns into a single label.
  3. 3Use Column From Examples for tricky splits.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge