Text.InferNumberType
TextInfers the most specific numeric type that can represent the given text value.
Syntax
Text.InferNumberType(text as text, optional culture as nullable text) as typeParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The text representation of a number. |
culture | text | No | A culture string (e.g., "en-US", "de-DE") that controls how number formats are parsed. Defaults to the current locale. |
Return Value
type — A Power Query type value such as type Int8, type Int64, type Double, or type Decimal that best represents the number in text.
Remarks
Text.InferNumberType examines a text string that represents a number and returns the most precise M type value that can represent it without loss of information. For example, "42" returns type Int8, while "3.14" returns type Double. The returned value is a Power Query type — not a number itself.
This is an advanced function primarily used in custom connector development, schema inference engines, and data profiling tools. In typical data transformation work, you would use Int64.From, Decimal.From, or Number.From directly rather than inferring the type first.
Always specify the culture parameter explicitly for predictable, locale-independent results. Without it, the function uses the current system locale, which means a query that works on one machine may parse numbers differently on another. For example, with "de-DE", the string "1.234,56" is interpreted as 1234.56 (period as thousands separator, comma as decimal separator), while "en-US" expects the opposite convention.
Examples
Example 1: Infer the type for a small integer
Text.InferNumberType("42", "en-US")Result | |
|---|---|
| 1 | type Int8 |
Example 2: Infer the type for a decimal value
Text.InferNumberType("3.14159", "en-US")Result | |
|---|---|
| 1 | type Double |
Example 3: Infer type using a European locale
Text.InferNumberType("1.234,56", "de-DE")Result | |
|---|---|
| 1 | type Double |