Number.FromText
Reads a number written as text, in the query's culture or in one you name.
Group: Number. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Number.FromText(text as nullable text, optional culture as nullable text) as nullable number
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to read: digits with the culture's separators, a sign, an exponent such as 1.5e3, or a trailing %. |
culture | nullable text optional | A culture's name, such as "nb-NO" or "de-DE"; the query's culture when left out. |
Returns
nullable number. The number; null for null.
Remarks
- Spaces before and after are ignored. Text that isn't a number in the culture is a DataFormat.Error.
- In en-US a comma groups thousands, so "12,5" reads as 125: name the culture when the text is written with a decimal comma.
- Only text is accepted;
Number.Fromalso takes dates, times, durations and logicals.
Examples
A decimal comma
Number.FromText("12,5", "nb-NO")
12.5
The same text in en-US
Number.FromText("12,5")
125
The comma is taken as a thousands separator.
Not a number
Number.FromText("n/a")
Result: an error.
[Reason = "DataFormat.Error", Message = "We couldn't convert to Number.", Detail = "n/a"]