OpenBI Docs Buy

Currency.From

A value as a fixed decimal number with four decimal places, the kind Currency.Type columns hold.

Group: Values, types and errors. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Currency.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
ParameterTypeDescription
valueanyThe value to convert: a number, text, a logical, a date, datetime, time or duration; null gives null.
culturenullable text
optional
The culture text is read in, such as "nb-NO"; the query's culture when left out.
roundingModenullable number
optional
Where a half goes: RoundingMode.ToEven (the default), RoundingMode.AwayFromZero, RoundingMode.Up, RoundingMode.Down or RoundingMode.TowardZero. Any other fraction goes to the nearest number whatever the mode.

Returns

nullable number. The number rounded to four decimal places; null for null.

Remarks

  • Past the fourth decimal the number is rounded to the nearest; a half goes to the even neighbour unless a rounding mode says otherwise.
  • The number is first taken as the decimal Power Query shows for it, 15 significant digits, so a computed 1.23455 counts as a half.
  • A currency holds amounts from -922,337,203,685,477.5808 to 922,337,203,685,477.5807: a larger one is an error.
  • Text is read in the culture; a value that isn't a number is an error.

Examples

Five decimals become four

Currency.From("1.23455")
1.2346

The half goes to the even 6.

A Norwegian price

Currency.From("19,99", "nb-NO")
19.99

A half rounded down

Currency.From(1.23455, null, RoundingMode.Down)
1.2345

Only a half follows the mode: 1.23459 would still give 1.2346.

Decimal.From, Number.Round, Number.From.

Last updated · OpenBI Studio 0.3.79