OpenBI Docs Buy

Table.SplitColumn

Splits one column into several, with a splitter such as one for a delimiter or for positions.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.SplitColumn(table as table, sourceColumn as text, splitter as function, optional columnNamesOrNumber as any, optional default as any, optional extraColumns as any) as table
ParameterTypeDescription
tabletableThe table with the column to split.
sourceColumntextThe column to split.
splitterfunctionA splitter that turns a value into a list of parts, such as Splitter.SplitTextByDelimiter("-").
columnNamesOrNumberany
optional
The new columns' names, or how many there are (named after the column: Sku.1, Sku.2 ...).
defaultany
optional
The value for the new columns a cell has no part for; null when left out.
extraColumnsany
optional
What to do with parts beyond the new columns: ExtraValues.Ignore, ExtraValues.List or ExtraValues.Error.

Returns

table. The new columns where the source column was; the other columns as they were.

Remarks

  • Parts beyond the new columns are dropped without an error by default. Transform data writes the column names it saw when you split, so data that later has more parts loses them: give more columns, or split into rows instead.
  • A cell with fewer parts gets the default (null) in the columns left over; a null cell gives null in every new column.

Examples

A code in two parts

Table.SplitColumn(#table({"Order", "Sku"}, {{1, "CH-0042"}, {2, "DK-0117"}}), "Sku", Splitter.SplitTextByDelimiter("-"), {"Category", "Number"})
OrderCategoryNumber
1CH0042
2DK0117

By positions

Table.SplitColumn(#table({"Sku"}, {{"CH0042"}, {"DK0117"}}), "Sku", Splitter.SplitTextByPositions({0, 2}), {"Category", "Number"})
CategoryNumber
CH0042
DK0117

Fewer and more parts than columns

Table.SplitColumn(#table({"Sku"}, {{"CH-0042"}, {"DK"}, {"LP-0007-B"}}), "Sku", Splitter.SplitTextByDelimiter("-"), {"Category", "Number"})
CategoryNumber
CH0042
DKnull
LP0007

DK has no number, so it gets null; the B of the last code is dropped.

Splitter.SplitTextByDelimiter, Splitter.SplitTextByPositions, Table.CombineColumns, Table.ExpandListColumn.

Last updated · OpenBI Studio 0.3.79