Splitter.SplitTextByLengths

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 the Splitter.SplitTextByLengths function can be used on its own, it is also used by the following functions:

Other functions related to Splitter.SplitTextByLengths are:

BI Gorilla Blog

Last update: November 17, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/splitter-splittextbylengths
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.