Splitter.SplitTextByWhitespace

Splitter

Returns a splitter function that splits text on whitespace characters, with optional CSV quoting behavior.

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

Syntax

Splitter.SplitTextByWhitespace(optional quoteStyle as nullable number) as function

Parameters

NameTypeRequiredDescription
quoteStylenumberNoControls how quoted strings containing whitespace are handled. Use QuoteStyle.None (default) or QuoteStyle.Csv to preserve whitespace within double-quoted segments.

Return Value

functionA function that splits text at whitespace boundaries.

Remarks

Splitter.SplitTextByWhitespace returns a splitter function that divides text at sequences of whitespace characters (spaces, tabs, and other Unicode whitespace). Multiple consecutive whitespace characters are treated as a single separator, and leading/trailing whitespace does not produce empty strings at the start or end.

The optional quoteStyle parameter controls whether content within double quotes is preserved as a single token even if it contains whitespace. Passing QuoteStyle.Csv enables CSV-style quoting, where "Hello World" is treated as a single token.

This splitter is commonly used with Table.SplitColumn to tokenize space-separated values or normalize inconsistently spaced data.

Examples

Example 1: Split on whitespace

Splitter.SplitTextByWhitespace()("Hello   World  Power Query")
Result
Result
1Hello,World,Power,Query

Example 2: Leading and trailing whitespace produces no empty elements

Splitter.SplitTextByWhitespace()("  apple  banana  ")
Result
Result
1apple,banana

Example 3: Preserve quoted tokens with CSV quote style

Splitter.SplitTextByWhitespace(QuoteStyle.Csv)("one ""two words"" three")
Result
Result
1one,two words,three

Example 4: Use with Table.SplitColumn

Table.SplitColumn(
    #table({"Tags"}, {{"alpha beta gamma"}}),
    "Tags",
    Splitter.SplitTextByWhitespace()
)
Result
Tags.1
Tags.2
Tags.3
1alphabetagamma

Compatibility

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