Text.Select

Text

Returns a text value containing only the characters from the input that match the specified selector.

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

Syntax

Text.Select(text as nullable text, selectChars as any) as nullable text

Parameters

NameTypeRequiredDescription
texttextYesThe text to filter.
selectCharsanyYesA character, list of characters, or a character class specification (such as a range) identifying which characters to keep.

Return Value

textA text value containing only the characters that satisfy the selector.

Remarks

Text.Select is the complement of Text.Remove — it keeps only the characters you specify and discards everything else. The selector can be a single character, a list of characters, or a character class range such as {"0".."9"} to keep only digits.

This is useful for extracting numeric digits from mixed text, keeping only alphabetic characters, or filtering to a known safe character set.

Examples

Example 1: Extract digits from a mixed string

Text.Select("Phone: 555-1234", {"0".."9"})
Result
Result
15551234

Example 2: Keep only alphabetic characters

Text.Select("Hello, World! 123", {"A".."Z", "a".."z"})
Result
Result
1HelloWorld

Compatibility

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