Skip to main content
The Calculator transformation component lets you perform calculations on your data, and add the results of these calculations as new columns. By default, all existing columns are included in the output as well. However, if you use this component to create a new column with the same name as an existing column, the existing data will be overwritten. This component is equivalent to writing a SELECT query, where the calculated expressions are in-line after the SELECT statement.

Use case

This component is extremely versatile and can be used to perform a wide range of calculations on your data. For example, you can use it to:
  • Perform mathematical operations, such as calculating year-over-year growth.
  • Perform string manipulations, such as converting email addresses to lower case.
  • Perform operations with conditions, such as assigning values to customers based on their total spend.
While you can use the Calculator component for the following use cases, we recommend using ‘s specialized components that are each designed for these purposes:

Properties

Name
string
required
A human-readable name for the component.
Include input columns
boolean
required
When Yes, all input columns are mapped without modification. When No, the component will output only columns that have been mapped manually via the expression editor. The default setting is Yes.
Calculations
expression editor
required
A list of SQL expressions calculated per row of data. The name of the expression becomes the output column.Click the field to open the Calculations dialog.Expressions: The panel on the left lists the named expressions. The name of each expression becomes an output column in the result.
  • +: Click + to add a new expression.
  • -: Click - to remove the selected expression.
Fields: Lists the input columns available from the upstream data flow. You can reference these columns in your expressions.Write the SQL expression for the selected name in the code editor on the right. Each expression must be valid SQL and can use all of the built-in functions supported by your cloud data warehouse:The following operator shortcuts are available at the bottom of the editor: AND, OR, NOT, +, -, *, /, ||, =, !=, <, <=, =>, >.Expressions can refer to an earlier expression by enclosing the existing expression name in double quotes.To use warehouse functions or variables in this field, type the name of the function or variable prefixed by the dollar symbol and surrounded by { } brackets, as follows: ${variable}. Once you type ${, a drop-down list of autocompleted suggested functions and variables will appear. This list updates as you type; for example, if you type ${DAY, functions and variables containing DAY will be listed. This list also shows the type of each function or variable.You can also use the Prompt Maia to write expressions field at the top of the editor to generate expressions using AI. Review any expressions generates before saving them.To use grid variables, toggle Use Grid Variable on at the bottom of the dialog. For more information, read Grid variables.