ROUND Function

Rounds input value to the nearest integer. Input can be an Integer, a Decimal, a column reference, or an expression.

  • Decimal values that are X.5 or more are rounded to X+1.

Basic Usage

Numeric literal example:

derive value: ROUND(2.5)

Output: Generates a column with each row's value 3.

Expression example:

derive value: ROUND(MyValue + 2.5)

Output: Generates a column containing the nearest integer to the sum of 2.5 and the value in the MyValue column.

Syntax

derive value: ROUND(numeric_value)

ArgumentRequired?Data TypeDescription
numeric_valueYstring, decimal, or integerName of column or Decimal or Integer literal to apply to the function

For more information on syntax standards, see Language Documentation Syntax Notes.

numeric_value

Name of the column, numeric literal, or numeric expression.

  • Missing input values generate missing results.
  • Literal numeric values should not be quoted. Quoted values are treated as strings.
  • Multiple columns and wildcards are not supported.

Usage Notes:

Required?Data TypeExample Value
YesString (column reference) or Integer or Decimal literal2.5

Examples

Example - Exponential functions

The following example demonstrates how the rounding functions work together. These functions include the following:

  • FLOOR - largest integer that is not greater than the input value. See FLOOR Function.
  • CEILING - smallest integer that is not less than the input value. See CEILING Function.
  • ROUND - nearest integer to the input value. See ROUND Function.
  • MOD - remainder integer when input1 is divided by input2. See Numeric Operators.

Source:

rowNumX
1-2.5
2-1.2
30
41
51.5
62.5
73.9
84
94.1
1011

Transform:

derive value: FLOOR (X) as: 'floorX'

derive value: CEILING (X) as: 'ceilingX'

derive value: ROUND (X) as: 'roundX'

derive value: (X % 2) as: 'modX'


Results:

rowNumXmodXroundXceilingXfloorX
1-2.5 -2-2-3
2-1.2 -1-1-2
300000
411111
51.5 221
62.5 332
73.9 443
840444
94.1 454
10111111111

Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Dataprep Documentation