ROUND
A number rounded to a number of decimals (negative: to tens, hundreds…), halves away from zero.
Group: Math. Compatible with DAX.
Syntax
ROUND ( <number>, <num_digits> )
| Parameter | Type | Description |
|---|---|---|
number | Number | The value whose decimals are rounded. |
num_digits | Whole number | How many decimals to keep: 0 for a whole number, a negative number for tens, hundreds and so on. |
Returns
Number. The number rounded to that many decimals, a half going away from zero.
Remarks
- A half goes away from zero:
ROUND ( 2.5, 0 )is 3 andROUND ( -2.5, 0 )is -3. There is no rounding to the even neighbour (banker's rounding). - Numbers round as they are written:
ROUND ( 2.345, 2 )is 2.35 andROUND ( 1.005, 2 )is 1.01, although the computer holds 1.005 as a hair less. - A negative num_digits rounds to the left of the decimal point:
ROUND ( 1234.567, -2 )is 1200. - num_digits is itself rounded to a whole number first: 0.4 means 0 decimals.
- A blank gives BLANK. A whole number stays a whole number and a Currency value stays a Currency value.
- Rounding every row and then adding differs from adding and then rounding: three rows of 1.4 rounded one by one add up to 3, their total 4.2 rounds to 4. Round where the number is shown.
Examples
Halves and negative digits
EVALUATE
ROW (
"2.5", ROUND ( 2.5, 0 ),
"-2.5", ROUND ( -2.5, 0 ),
"2.345 to 2", ROUND ( 2.345, 2 ),
"1234.567 to -2", ROUND ( 1234.567, -2 )
)
| 2.5 | -2.5 | 2.345 to 2 | 1234.567 to -2 |
|---|---|---|---|
| 3 | -3 | 2.35 | 1200 |
Rounding rows or the total
EVALUATE
VAR Amounts = DATATABLE ( "Amount", DOUBLE, { { 1.4 }, { 1.4 }, { 1.4 } } )
RETURN
ROW (
"Rounded rows", SUMX ( Amounts, ROUND ( [Amount], 0 ) ),
"Rounded total", ROUND ( SUMX ( Amounts, [Amount] ), 0 )
)
| Rounded rows | Rounded total |
|---|---|
| 3 | 4 |