Splitter.SplitTextByPositions

Updated on

Splitter.SplitTextByPositions is a Power Query M function that splits text into a list at each specified position. The function returns a list of text segments after applying the position-based splitting.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Splitter.SplitTextByPositions(
   positions as list,
   optional startAtEnd as nullable logical,
) as function

Description

Returns a function that splits text into a list of text at each specified position.

Examples

Split the input at the specified positions, starting from the beginning of the input.

// Output: {"ABC", "|", "12345"}
Splitter.SplitTextByPositions( {0, 3, 4} )( "ABC|12345" )

Split the input at the specified positions, starting from the end of the input.

// Output: {"Redmond", "98052"}
let
    startAtEnd = true
in
    Splitter.SplitTextByPositions( {0, 5}, startAtEnd )( "Redmond98052" )

Used by

While you can use the Splitter.SplitTextByPositions function by itself, it also works together with:

Other functions related to Splitter.SplitTextByPositions are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/splitter-splittextbypositions