Number.FromText
NumberConverts a text representation of a number to a number value, with optional locale-aware parsing.
Syntax
Number.FromText(text as nullable text, optional culture as nullable text) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The text string to convert to a number. |
culture | text | No | An optional culture string (e.g., "en-US", "de-DE") that controls how decimal and thousand separators are interpreted. |
Return Value
number — The numeric value represented by the text string.
Remarks
Number.FromText parses a text value into a number. It recognizes integers, decimal numbers, and scientific notation (e.g., "1.5e3" → 1500). It also recognizes the special strings "NaN", "Infinity", and "-Infinity". When no culture is specified, the engine uses the session locale.
The most important use of the optional culture parameter is handling locale-specific decimal and thousands separators. In "en-US", the decimal separator is . and the thousands separator is , (e.g., "1,234.56"). In "de-DE" (German) and many European locales, these are reversed: . is the thousands separator and , is the decimal (e.g., "1.234,56"). Failing to specify the correct culture will cause parsing errors or silently incorrect values.
Number.FromText raises an error if the text cannot be parsed as a number. Use try Number.FromText(text) otherwise null to safely handle unparseable values in bulk conversions. For simple type conversion without locale concerns, Number.From(value) is a more concise alternative that handles the same cases plus non-text inputs.
Examples
Example 2: Parse a German-formatted number with culture
Number.FromText("1.234,56", "de-DE")Result | |
|---|---|
| 1 | 1,234.56 |
Example 3: Safely parse a text column that may contain non-numeric values
let
Data = #table({"ID", "PriceText"}, {{1, "25.00"}, {2, "N/A"}, {3, "75.50"}}),
WithParsed = Table.AddColumn(
Data,
"Price",
each try Number.FromText([PriceText]) otherwise null,
type number
)
in
WithParsedThe final output — the table with a parsed Price column where unparseable text produces null rather than an error.
ID | PriceText | Price | |
|---|---|---|---|
| 1 | 1 | 25.00 | 25 |
| 2 | 2 | N/A | null |
| 3 | 3 | 75.50 | 75.50 |