Number.Round

Updated on

Number.Round is a Power Query M function that rounds a given number to the nearest integer, with support for optional parameters to control decimal digits and rounding mode. The function returns the rounded number or null if the input is null.

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

Syntax

Number.Round(
   number as nullable number,
   optional digits as nullable number,
   optional roundingMode as nullable number,
) as nullable number
ArgumentAttributeDescription
numberThe number to round.
digitsoptionalDefines the number of decimal places for rounding.
roundingModeoptionalThe RoundingMode.Type argument controls the rounding method applied. When omitted, the function uses RoundingMode.ToEven, which rounds to the nearest even number in tie situations. Other options include:
RoundingMode.Up rounds up in such cases.
RoundingMode.Down rounds down.
RoundingMode.TowardZero rounds toward zero.
RoundingMode.AwayFromZero rounds away from zero.

Description

The Number.Round function rounds a given number to the nearest value. If the input is null, it returns null. By default, it rounds to the nearest integer, applying “banker’s rounding” (RoundingMode.ToEven), which breaks ties by rounding to the nearest even number. This behavior can be customized with optional “digits” and “roundingMode” parameters.

Examples

Round 1.234 to the nearest integer.

Number.Round( 1.234 ) // Returns 1

Round 1.56 to the nearest integer.

Number.Round( 1.56 ) // Returns 2

Round 1.2345 to two decimal places.

Number.Round( 1.2345, 2 ) // Returns 1.23

Round 1.2345 to three decimal places ( Rounding up ).

Number.Round( 1.2345, 3, RoundingMode.Up ) // Returns 1.235

Round 1.2345 to three decimal places ( Rounding down ).

Number.Round( 1.2345, 3, RoundingMode.Down ) // Returns 1.234

Other functions related to Number.Round are:

BI Gorilla Blog

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