Character.ToNumber

Text

Returns the Unicode code point number for the given character.

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

Syntax

Character.ToNumber(character as text) as number

Parameters

NameTypeRequiredDescription
charactertextYesA single-character text value.

Return Value

numberThe numeric Unicode code point of the character.

Remarks

Character.ToNumber returns the Unicode code point (an integer) for the given single character. This is the inverse of Character.FromNumber. The input must be exactly one character long — passing a multi-character string or an empty string raises an error.

The primary use of this function is character classification: you can test whether a character falls within a known Unicode range to determine if it is a digit (48–57), uppercase letter (65–90), lowercase letter (97–122), or a control character (0–31). This approach is faster than converting to a list and filtering when you only need to classify one character at a time.

When processing every character in a string, combine Text.ToList with List.Transform to apply Character.ToNumber across all characters at once. The resulting list of code points can then be filtered or analyzed with standard list functions.

Note that Power Query text comparisons are case-sensitive by default. If you need to classify characters without regard to case, compare against both the uppercase and lowercase ranges, or normalize the character with Text.Upper or Text.Lower first.

Examples

Example 1: Get the code point for a character

Character.ToNumber("A")
Result
Result
165

Example 2: Check whether a character is a digit

let
    ch = "7",
    code = Character.ToNumber(ch),
    isDigit = code >= 48 and code <= 57
in
    isDigit
Applied Steps

The final output — a logical true, confirming that "7" is a digit character.

Result
1TRUE

Example 3: Get code points for each character in a string

List.Transform(Text.ToList("E001"), Character.ToNumber)
Result
Result
169,48,48,49

Compatibility

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