Number.Round

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

Description

Returns the result of rounding number to the nearest number. If number is null, Number.Round returns null.

By default, number is rounded to the nearest integer, and ties are broken by rounding to the nearest even number (using RoundingMode.ToEven, also known as “banker’s rounding”).

However, these defaults can be overridden via the following optional parameters.

  • digits: Causes number to be rounded to the specified number of decimal digits.
  • roundingMode: Overrides the default tie-breaking behavior when number is at the midpoint between two potential rounded values (refer to RoundingMode.Type for possible values).

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 Youtube Channel

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/number-round
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.