Skip to main content

Calculator

Feature Description

Calculator introduces a new column into the original dataset and generates its value based on specific calculation or transformation rules. It supports mathematical operations, conditional logic, string concatenation, and more based on existing columns.

By extending or combining existing columns, you can create new analytical metrics based on the existing data and build a more complete data view.

For example, in a product sales table, you can add a new Total Sales field whose value equals Sales Amount * Sales Quantity. You can also use time functions such as DATE_TRUNC(week,[Order Time]) to return the first day of the week corresponding to the Order Time field.

Procedure

  1. Drag the Calculator operator from the dataflow operator panel into the canvas on the right.

  2. Click the Calculator operator, then click Add Calculated Field. Multiple fields are supported.

    • Enter the field name, choose the field type, and write the calculation formula.
    • Supported field types are Numeric, Text, Date, Date and Time, and Boolean.
    • Calculation formulas support basic arithmetic operations and can be combined with functions as needed.
  3. Time macro parameters, global parameters, and workflow parameters are supported.

  4. Click Confirm, then click Preview on the current node to verify the result.

Example: Extract the year from a date

  1. Add a Calculator after the node that supplies the date column. Rename the operator so you can identify it on the canvas.
  2. Select Add Calculated Field. Name the field Year, choose Text, and use YEAR([Date]), where [Date] is the input date field. The editor supports eight function categories, including aggregate statistics, non-aggregate statistics, and date/time functions. For the difference between calculating a value per row and aggregating rows, see Why does SUM fail in a new ETL field?.
  3. Confirm the settings and preview the output. Check that each row shows the year from its input date.