Work with numbers

This page explains how to perform numeric calculations when you prepare data inthe Wrangler workspace of the Cloud Data Fusion Studio.

You can perform these transformations in columns of the following data types:

  • Integer
  • Decimal
  • Double
  • Float
  • Long
  • Short
Note: To use numeric functions on decimal columns, use theWrangler CLI.

For more information, see theset-column directive.

You can use numeric functions on one or more columns. The available numericfunctions vary by the number of columns you select. You can choose to create anew column with the results of the calculations, or you can have the resultsappear in the column where you add the transformation.

If you apply a numericfunction to a single column, the behavior is different than if you apply anumeric function to multiple columns. For example:

  • If you use theMultiply() function ona single column, you specify thedecimal value to multiply each value in the column by. Wrangler performs themultiplication on the sample data and displays the new values in the samecolumn or in a new column.
  • If you use theMultiply() function onmultiple columns, Wranglermultiplies the values in each row for the selected columns and displays thenew values in the first column of the transformation.

Perform numeric calculations on values in one column

To apply a numeric calculation to one column, follow these steps:

  1. Go to the Wrangler workspace in Cloud Data Fusion.
  2. On theData tab, go to a column name and click thearrow_drop_downexpander arrow.
  3. SelectCalculate and select an option—for example,Add.

    To complete the calculation, some functions require you to enter a decimalvalue. For example, if you selectSubtract, you must enter the value tosubtract from each row.

  4. Optional: to create a new column for the calculated values, select theCopy to a new column checkbox.

  5. ClickApply.

The values change based on the calculation. Wrangler adds the correspondingdirective as a step in the recipe. For example, if you subtract two from eachvalue in thePrice column, Wrangler adds the following transformation to therecipe:

set-column :Price Price - 2

When you run the data pipeline, the transformation is applied to all values inthe column.

Supported calculations for one column

You can perform the following calculations on all values in one column:

FunctionDescription
Absolute valueReturns the absolute value for each value in a column. For example, the absolute value of -10 is 10.
AddAdds a positive or negative decimal to a column or adds multiple columns to output the sum of each row.
ArccosReturns the inverse of cosine for each value in a column.
ArcsinReturns the inverse of sin for each value in a column.
ArctanReturns the inverse of tangent for each value in a column.
CeilReturns the smallest integer greater than or equal to the numeric value in each cell of a column. For example, if the value is 2.21, Ceil returns 3. If the value is 5.88, Ceil returns 6. If the value is -5.15, Ceil returns -5.
CosReturns cosine of each column value.
CubeRaises each value in the column to the power of 3.
Cube rootReturns the cube root of each value in the column.
DivideDivides each value in the column by a positive or negative decimal or divides each value in two columns.
FloorReturns the largest integer greater than or equal to the numeric value in each cell of a column. For example, if the value is 2.21, FLOOR returns 2. If the value is 5.88, FLOOR returns 5. Likewise, if the value is -5.15, FLOOR returns -6.
LogReturns the logarithm of each value in a column.
ModuloReturns the remainder when dividing each value in the column by a positive decimal or returns the remainder when dividing each value in two columns.
MultiplyMultiplies each value in the column by a positive or negative decimal or multiplies each value in two columns.
Natural LogReturns the natural logarithm of each value in a column.
Power ofRaises the column value to the specified power of value.
RandomGenerates random, unpredictable Double values in a specified column.
RoundRounds each value in a column.
SinReturns the sin for each value in a column.
SquareRaises each value in the column to the power of 2.
Square rootReturns the square root of each value in a column.
SubstractSubtracts a positive or negative decimal to each value in the column.
TanReturns the tangent for each value in a column.

Perform numeric calculations on values in two columns

To apply a numeric calculation to two columns, follow these steps:

  1. Go to the Wrangler workspace in Cloud Data Fusion.
  2. On theData tab, select the checkbox by two column names.
  3. Go to a column name and click thearrow_drop_downexpander arrow.
  4. SelectCalculate and select an option—for example,Add.
  5. Optional: to create a new column for the calculated values, select theCopy to a new column checkbox. Otherwise, the calculated values overrideexisting values.
  6. ClickApply.

The values change based on the calculation. Wrangler adds the correspondingdirective as a step in the recipe. For example, if you add the values in each rowof theQ1_Sales andQ2_Sales columns and create a new column calledH1_Sales, Wrangler adds the following transformation to the recipe:

set-column :H1_Sales arithmetic:add(Q1_Sales, Q2_Sales)

When you run the data pipeline, Wrangler performs the transformation and createsa new column calledH1_Sales with the total ofQ1_Sales andQ2_Sales.

Supported calculations in two columns

You can perform the following numeric calculations on values in each row in twocolumns:

FunctionDescription
AddAdds a positive or negative decimal to a column or adds multiple columns to output the sum of each row.
AverageReturns the average of each row in multiple columns.
DivideDivides each value in the column by a positive or negative decimal or divides each value in two columns.
EqualBoolean function that compares two columns to see if values match, row by row. Returnstrue orfalse.
LCMReturns the least common multiple of each number in two columns.
MaxReturns the maximum value for each row in two columns.
MinReturns the minimum value for each row in two columns.
ModuloReturns the remainder when dividing each value in the column by a positive decimal or returns the remainder when dividing each value in two columns.
MultiplyMultiplies each value in the column by a positive or negative decimal or multiplies each value in two columns.
SubtractSubtracts a positive or negative decimal to each value in the column.

Perform numeric calculations on values in three or more columns

Cloud Data Fusion supports performing numeric calculations on values inthree or more columns in version 6.8.0 and later.

To apply a numeric calculation to three or more columns, follow these steps:

  1. Go to the Wrangler workspace in Cloud Data Fusion.
  2. On theData tab, select the checkbox by two column names.
  3. Go to a column name and click thearrow_drop_downexpander arrow.
  4. SelectCalculate and select an option—for example,Add.
  5. Optional: to create a new column for the calculated values, select theCopy to a new column checkbox. Otherwise, the calculated values overrideexisting values.
  6. ClickApply.

The values change based on the calculation. Wrangler adds the correspondingdirective as a step in the recipe. For example, if you add the values in each rowof theQ1_Sales,Q2_Sales,Q3_Sales, andQ4_Sales columns and create anew column called2022_Sales, Wrangler adds the following transformation tothe recipe:

set-column :2022_Sales arithmetic:add(Q1_Sales, Q2_Sales, Q3_Sales, Q4_Sales)

When you run the data pipeline, Wrangler performs the transformation and createsa new column called2022_Sales with the total ofQ1_Sales,Q2_Sales,Q3_Sales, andQ4_Sales.

Supported calculations in three or more columns

You can perform the following calculations on values in each row in three ormore columns:

FunctionDescription
AddAdds a positive or negative decimal to a column or adds multiple columns to output the sum of each row.
AverageReturns the average of each row in multiple columns.
EqualBoolean function that compares two columns to see if values match, row by row. Returnstrue orfalse.
MaxReturns the maximum value for each row in two columns.
MinReturns the minimum value for each row in two columns.
MultiplyMultiplies each value in the column by a positive or negative decimal or multiplies each value in two columns.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.