Splitter.SplitTextByRepeatedLengths

Splitter

Returns a splitter function that repeatedly splits off substrings of a fixed length from the text.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Splitter.SplitTextByRepeatedLengths(length as number, optional startAtEnd as nullable logical) as function

Parameters

NameTypeRequiredDescription
lengthnumberYesThe fixed number of characters for each chunk.
startAtEndlogicalNoWhen true, chunks are taken from the end of the string first. Defaults to false.

Return Value

functionA function that splits text into consecutive fixed-length chunks.

Remarks

Splitter.SplitTextByRepeatedLengths returns a splitter function that slices its input into consecutive chunks of the specified length. If the text length is not evenly divisible by length, the final chunk contains the remaining characters.

When startAtEnd is true, chunks are taken from the right side of the string first, so the potentially shorter partial chunk appears at the beginning of the result list.

This is useful for parsing packed binary-format text strings, segmenting hex data, chunking encoded strings, or splitting data into fixed-size page-width columns.

Examples

Example 1: Split into chunks of three characters

Result
Result
1ABC,DEF,GHI

Example 2: Remainder in the last chunk

Result
Result
1ABCD,EFGH,IJ

Example 3: Split from the end (remainder first)

Result
Result
1AB,CDEF,GHIJ

Example 4: Split a hex string into bytes

Result
Result
148,65,6C,6C,6F

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks