Decimal.From
NumberConverts a value to a decimal (fixed-point) number with high precision for exact decimal arithmetic.
Syntax
Decimal.From(value as any, optional culture as nullable text) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert. Accepts number, text, logical, or null. |
culture | text | No | An optional culture string for locale-aware parsing of text values. |
Return Value
number — A decimal number with exact fixed-point representation.
Remarks
Decimal.From converts a value to the decimal number type, which uses fixed-point arithmetic rather than binary floating-point. In Power Query M, "Decimal Number" in the UI corresponds to this type, which maps to the .NET Decimal type with 28–29 significant digits of precision. The default number type in M is a 64-bit IEEE 754 double, which cannot represent all decimal fractions exactly.
The most practical implication is that values like 0.1, 0.2, and 0.3 are stored exactly as Decimal but are approximated in binary floating-point (double). Summing thousands of currency or tax amounts using double arithmetic can introduce small cumulative rounding errors that would not occur with decimal arithmetic. For this reason, Decimal.From is preferred over Double.From in financial data modeling.
Compared to Currency.From, the decimal type is more general: it is not limited to 4 decimal places and supports up to 28–29 significant digits. Use Decimal.From when you need high-precision fixed-point arithmetic without the 4-decimal-place constraint of the currency type. Text values are parsed using the specified culture — pass "de-DE" for German-format numbers, for example. Logical true converts to 1, false to 0, and null returns null.
Examples
Example 1: Exact decimal arithmetic avoids floating-point drift
Decimal.From(0.1) + Decimal.From(0.2)Result | |
|---|---|
| 1 | 0.30 |
Example 2: Parse a text value with 4 decimal places
Decimal.From("1234.5678")Result | |
|---|---|
| 1 | 1,234.57 |
Example 3: Apply decimal type to price column in Sales
Table.TransformColumnTypes(
Table.SelectColumns(Table.FirstN(Sales, 4), {"OrderID", "CustomerName", "UnitPrice"}),
{{"UnitPrice", Decimal.Type}}
)OrderID | CustomerName | UnitPrice | |
|---|---|---|---|
| 1 | 1 | Alice | 25 |
| 2 | 2 | Bob | 50 |
| 3 | 3 | Charlie | 15 |
| 4 | 4 | Alice | 75 |