Splitter.SplitTextByLengths

Updated on

Splitter.SplitTextByLengths is a Power Query M function that splits text into a list based on the specified lengths. The function returns a list of text segments after applying the length-based splitting.

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

Syntax

Splitter.SplitTextByLengths(
   lengths as list,
   optional startAtEnd as nullable logical,
) as function

Description

Returns a function that splits text into a list of text by each specified length.

Examples

Split the input into the first two characters followed by the next three, starting from the beginning of the input.

// Output: {"AB", "123"}
Splitter.SplitTextByLengths( {2, 3} )( "AB123" )

Split the input into the first three characters followed by the next two, starting from the end of the input.

// Output: {"WA", "98052"}
let
    startAtEnd = true
in
    Splitter.SplitTextByLengths( {5, 2}, startAtEnd )( "RedmondWA98052" )

Used by

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

Other functions related to Splitter.SplitTextByLengths are:

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