OpenBI Docs Buy

Splitter.SplitTextByPositions

Makes a function that cuts text at given character positions, each piece running to the next position.

Group: Splitters, combiners, replacers and comparers. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Splitter.SplitTextByPositions(positions as list, optional startAtEnd as nullable logical) as function
ParameterTypeDescription
positionslistWhere each piece starts, counted from 0, in ascending order.
startAtEndnullable logical
optional
true to work from the end of the text toward its start.

Returns

function. A splitter: given a text, a piece for each position, the last running to the end.

Remarks

  • A splitter is a function of one text that gives a list of texts. Table.SplitColumn and Table.FromList take one; you can also call it yourself, as the examples do.
  • Positions count characters from 0: position 2 is the third character. With startAtEnd they count back from the end of the text.

Examples

Three fields of a code

Splitter.SplitTextByPositions({0, 2, 6})("NO0150OSL")
{"NO", "0150", "OSL"}

The country and the rest

Splitter.SplitTextByPositions({0, 2})("NO0150OSL")
{"NO", "0150OSL"}

Splitter.SplitTextByLengths, Text.Middle, Table.SplitColumn.

Last updated · OpenBI Studio 0.3.79