Splitter.SplitTextByRanges

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

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

Syntax

Splitter.SplitTextByRanges(
   ranges as list,
   optional startAtEnd as nullable logical,
) as function

Description

Returns a function that splits text into a list of text according to the specified offsets and lengths. A null length indicates that all remaining input should be included.

Examples

Split the input by the specified position and length pairs, starting from the beginning of the input. Note that the ranges in this example overlap.

// Output: {"code", "delimiter"}
Splitter.SplitTextByRanges( {{0, 4}, {2, 10}} )( "codelimiter" )

Split the input by the specified position and length pairs, starting from the end of the input.

// Output: {"WA", "98052"}
let
    startAtEnd = true
in
    Splitter.SplitTextByRanges( {{0, 5}, {6, 2}}, startAtEnd )( "RedmondWA?98052" )

Split the input into a fixed-length postal code followed by a variable-length city name.

// Output: {"98052", "Redmond"}
Splitter.SplitTextByRanges( {{0, 5}, {5, null}} )( "98052Redmond" )

Used by

While the Splitter.SplitTextByRanges function can be used on its own, it is also used by the following functions:

Other functions related to Splitter.SplitTextByRanges are:

BI Gorilla Youtube Channel

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