> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculator

export const maia = "Maia";

export const ComponentMetadata = ({warehouses, unsupportedWarehouses = [], componentType, connectionInputs, connectionOutputs}) => {
  const allWarehouses = [...warehouses.map(w => ({
    name: w,
    supported: true
  })), ...unsupportedWarehouses.map(w => ({
    name: w,
    supported: false
  }))];
  return <div style={{
    background: 'var(--colors-background-light, #f9fafb)',
    border: '1px solid var(--colors-border-default, #e5e7eb)',
    borderRadius: '12px',
    padding: '20px 28px',
    marginBottom: '28px',
    boxShadow: '0 1px 4px rgba(0,0,0,0.10)'
  }}>
      <table style={{
    width: '100%',
    borderCollapse: 'collapse'
  }}>
        <tbody>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle',
    width: '180px'
  }}>Project Availability</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>
              <div style={{
    display: 'flex',
    flexWrap: 'wrap',
    gap: '8px'
  }}>
                {allWarehouses.map((w, i) => <span key={i} style={{
    background: w.supported ? '#dcfce7' : '#fee2e2',
    color: w.supported ? '#15803d' : '#b91c1c',
    border: `1px solid ${w.supported ? '#bbf7d0' : '#fca5a5'}`,
    borderRadius: '9999px',
    padding: '3px 12px',
    fontSize: '0.85rem',
    fontWeight: '500',
    whiteSpace: 'nowrap'
  }}>
                    {w.name} {w.supported ? '✅' : '❌'}
                  </span>)}
              </div>
            </td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Component Type</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{componentType}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Inputs</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{connectionInputs}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Outputs</td>
            <td style={{
    verticalAlign: 'middle'
  }}>{connectionOutputs}</td>
          </tr>
        </tbody>
      </table>
    </div>;
};

<ComponentMetadata warehouses={["Snowflake", "Databricks", "Amazon Redshift", "Google BigQuery"]} componentType="Transformation" connectionInputs="One" connectionOutputs="Unlimited" />

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 {maia}'s specialized components that are each designed for these purposes:

* To profile your data, identify data quality issues, and improve the quality of your dataset, use [Data Cleanse](/docs/components/data-cleanse).
* To extract JSON or semi-structured data, use [Extract Nested Data](/docs/components/extract-nested-data) or [Flatten Variant](/docs/components/flatten-variant).
* To implement simple filters, use [Filter](/docs/components/filter).
* To make changes to data types, use [Convert Type](/docs/components/convert-type).

***

## Properties

<ResponseField name="Name" type="string" required>
  A human-readable name for the component.
</ResponseField>

{/* <!-- param-start:[includeInputColumns] | warehouses: [snowflake, databricks, redshift, bigquery] --> */}

<ResponseField name="Include input columns" type="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**.
</ResponseField>

{/* <!-- param-start:[calculations] | warehouses: [snowflake, databricks, redshift, bigquery] --> */}

<ResponseField name="Calculations" type="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:

  * [Snowflake functions](https://docs.snowflake.net/manuals/sql-reference/functions-all.html)
  * [Databricks functions](https://docs.databricks.com/en/sql/language-manual/sql-ref-functions-builtin.html)
  * [Amazon Redshift functions](https://docs.aws.amazon.com/redshift/latest/dg/c_SQL_functions.html)
  * [Google BigQuery functions](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators)

  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 { maia } 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](/docs/guides/grid-variables).
</ResponseField>
