Text.At

Text

Returns the character at the specified zero-based index position in a text value.

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

Syntax

Text.At(text as nullable text, index as number) as nullable text

Parameters

NameTypeRequiredDescription
texttextYesThe source text value.
indexnumberYesThe zero-based index of the character to return.

Return Value

textA single-character text value at the given index.

Remarks

Text.At returns a single character from text at the specified zero-based index. The first character is at index 0. It is equivalent to Text.Middle(text, index, 1) but expresses single-character access more clearly.

If text is null, the function returns null. If index is out of range — negative, or equal to or greater than the text length — an error is raised. Always validate the index or text length before calling this function on variable-length data to avoid runtime errors.

Use Text.At when you need a specific character by position. For extracting a range of characters, use Text.Middle or Text.Range. For iterating over every character, Text.ToList is more efficient than calling Text.At in a loop. To find the position of a character rather than retrieve it, use Text.PositionOf.

Examples

Example 1: Get the first character of a string

Text.At("Widget A", 0)
Result
Result
1W

Example 2: Extract the category prefix from a product code

Text.At("E001", 0)
Result
Result
1E

Example 3: Read the separator character in a formatted string

let
    code = "US-12345",
    sep = Text.At(code, 2),
    isValid = sep = "-"
in
    isValid
Applied Steps

The final output — checks whether the extracted separator character equals "-", returning true if the format is valid.

Result
1TRUE

Compatibility

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