Number.RoundAwayFromZero

Updated on

Number.RoundAwayFromZero is a Power Query M function that rounds a given number based on its sign, rounding positive numbers up and negative numbers down, with support for optional digits parameter. The function returns the rounded number.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Number.RoundAwayFromZero(
   number as nullable number,
   optional digits as nullable number,
) as nullable number

Description

Returns the result of rounding number based on the sign of the number. This function will round positive numbers up and negative numbers down. If digits is specified, number is rounded to the digits number of decimal digits.

Examples

Round the number -1.2 away from zero.

// Output: -2
Number.RoundAwayFromZero( -1.2 )

Round the number 1.2 away from zero.

// Output: 2
Number.RoundAwayFromZero( 1.2 )

Round the number -1.234 to two decimal places away from zero.

// Output: -1.24
Number.RoundAwayFromZero( -1.234, 2 )

Other functions related to Number.RoundAwayFromZero are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/number-roundawayfromzero