Ravindra BagaleCourses & study guides

7. Data Cleaning A–Z in Power Query

7.10 Split Columns (All Six Methods, Plus Split into Rows)

Transform › Split Column (also on Home) offers six methods. The examples below use our codes and product names.

Method Before After Setting used
By Delimiter BLK-PUN-KOT-01 BLK · PUN · KOT · 01 Delimiter "-", Each occurrence
By Number of Characters BLK250314 BLK · 250314 3 characters, Once, as far left as possible
By Positions 20250314KOT 20250314 · KOT Positions 0, 8
By Lowercase to Uppercase KothrudHub Kothrud · Hub –
By Uppercase to Lowercase PUNkothrud PUNk · othrud (usually not what you want) –
By Digit to Non-Digit 500ml 500 · ml –
By Non-Digit to Digit Poha1kg Poha · 1kg –

Steps in Power BI – split Store ID by delimiter

  1. Select Store ID (values like BLK-PUN-KOT-01).
  2. Transform › Split Column › By Delimiter.
  3. Select or enter delimiter: --Custom-- -; Split at: Each occurrence of the delimiter › OK.
  4. Rename the new columns Platform Code, City Code, Area Code, Store No. Keep Store No as Text.
  5. Tip: to keep the original column, use Add Column › Extract instead of splitting (7.12), or duplicate it first (Add Column › Duplicate Column).
Split = Table.SplitColumn(Source, "Store ID",
    Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv),
    {"Platform Code", "City Code", "Area Code", "Store No"})

Split into Rows

An order export sometimes lists all items of an order in one cell:

Before

Order ID Items
BLK-40001 Ladi Pav; Amul Butter; Poha
BLK-40002 Nashik Grapes

After

Order ID Items
BLK-40001 Ladi Pav
BLK-40001 Amul Butter
BLK-40001 Poha
BLK-40002 Nashik Grapes

Steps: select Items › Split Column › By Delimiter › delimiter (विभाजक चिन्ह, उदा. स्वल्पविराम) ; › expand Advanced options › Split into Rows › OK → Transform › Format › Trim.

ToLists  = Table.TransformColumns(Source, {{"Items", Splitter.SplitTextByDelimiter(";")}}),
ToRows   = Table.ExpandListColumn(ToLists, "Items"),
Trimmed  = Table.TransformColumns(ToRows, {{"Items", Text.Trim, type text}})

Ravindra Bagale's Tip

Look, friends: splitting into columns when the number of parts varies (3 items in one order, 7 in another) silently loses the extra parts, because the column count is fixed when the step is created. Split into rows in that case. After any split, check the automatic Changed Type step, which may turn "01" into 1. Try it once more, then move on.

Practice task

Simple bhashet sangaycha tar, split the Amazon Now Pack Size column ("500ml", "1kg", "12pcs") into Size Value and Size Unit using By Digit to Non-Digit, and set Size Value to Decimal Number.