OpenBI Docs Buy

Int32.From

A value as a 32-bit whole number (Int32.Type), its fraction rounded away.

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

Syntax

Int32.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 whole number; null for null.

Remarks

  • Text is read in the culture, the way Number.From reads it; a value that isn't a number is an error.
  • A fraction is rounded to the nearest whole number. A half goes to the even neighbour unless a rounding mode says otherwise: 4.5 becomes 4 and 5.5 becomes 6. The mode is used for a half only, so 12.1 is 12 even with RoundingMode.Up.
  • A number outside the type's range is an error, as in Power Query: from -2,147,483,648 to 2,147,483,647.

Examples

German number text

Int32.From("1.234,5", "de-DE")
1234

1234.5, rounded to even.

A half rounded up

Int32.From(12.5, null, RoundingMode.Up)
13

The mode decides where a half goes; 12.1 stays 12 with any mode.

Int64.From, Int16.From, Number.From.

Last updated · OpenBI Studio 0.3.79