Skip to Content

Create a metric

Add a calculated field

Make a new measure or dimension from the columns already in your metric.

Make a new measure or dimension from the columns already in your metric.

Before you start

  • The metric builder is on the Schema tab. Calculated fields are not on the SQL tab.
  • The well you add to (Dimensions or Measures) has at least one column.

Add a quick field

A quick field combines two columns, or a column and a number. It is for Measures only.

  1. In Measures, select Calculated field.

    Dimensions and Measures wells with the Calculated field button of Measures highlighted.
    Each well has its own Calculated field button at the right.
  2. Select Quick field.

    Calculated fields popover with the text No calculated fields and the Quick field button highlighted next to Write SQL.
    Choose Quick field or Write SQL.
  3. In Column, pick the first column. Set Cast as and Aggregate if you need them.

    New calculated field panel with the first Column field highlighted and set to profit, with Aggregate set to SUM.
    The first Column, with Cast as and Aggregate under it.
  4. Pick an operator: Add (+), Sub (-), Multiply (*) or Divide (/).

    New calculated field panel with the operator field highlighted and set to Divide (/).
    The operator sits between the two columns.
  5. In Value Type, choose Column or Number.

    New calculated field panel with the Value Type field highlighted and set to Column.
    Value Type decides if the second value is a column or a number.
  6. Pick the second column, or enter a number, for example 100.

    New calculated field panel with the second Column field highlighted and set to quantity sold.
    Pick the second column, with its own Cast as and Aggregate.
  7. In Save as, enter a name, for example revenue_per_order.

    New calculated field panel with profit_per_unit typed in the highlighted Save as field and the Save button.
    Save as is the name the field gets in Measures.
  8. Select Save.

The field shows in Measures with an fx badge. Select it to change it.

Write a SQL field

Use this for logic a quick field cannot do. It works in Dimensions and Measures.

  1. In the well, select Calculated field.

  2. Select Write SQL.

    Calculated fields popover with the Write SQL button highlighted.
    Write SQL is next to Quick field.
  3. In the Calculated Fields panel, pick the Table.

    Calculated Fields panel with the Table field highlighted and set to iceberg_parquet.dbn-demo_sales.
    The Calculated Fields panel opens on the right; pick the Table first.
  4. Enter a Query Name, for example net_revenue.

    Calculated Fields panel with net_revenue typed in the highlighted Query Name field.
    Query Name is the name of the new field.
  5. Write one column expression in the editor. Do not write a full SELECT query.

    Calculated Fields panel with the SQL editor highlighted, holding SUM of quantity sold times unit price, under Query Guidelines.
    Write one column expression; Query Guidelines above it shows the rules.
  6. Select Save.

Reference columns as "schemaName_tableName"."columnName", for example "public_orders"."amount". If the query uses another alias for the table, use that alias. Query Guidelines in the panel shows these rules.

The wand button, Format Column With AI, formats the expression with AI. It works only when Summarise metric data is on in the workspace settings.

Next, join, filter, sort and group the metric.

If something goes wrong

  • Calculated field is greyed out. Add a column to that well first.
  • Quick field is missing. It is only in Measures. Use Write SQL in Dimensions.
  • “x” is already used in this well. Enter a different name in Save as.