Celiq
v0.12Open app โ†—
Docs/Semantic Layer/Calculated Fields

Calculated Fields

The two ways Celiq creates calculated fields โ€” node-persisted definitions and ad-hoc Discover session fields built from existing columns.

WeaverTracerUpdated June 2026 ยท 6 min read
โœฆ
In this section
Part of Celiq's semantic layer platform. Connect your warehouse, model your data once, query it everywhere.
๐Ÿ’ก
Tip
What it is: Fields whose value is computed from an expression over other fields, rather than read directly from your warehouse.
When to use it: When you need a ratio or derived number (revenue per order, margin %, attach rate) that does not exist as a column or a modeled metric.
Where to find it: The CALCULATED section in the Discover field panel (left rail of Discover). Node-level definitions are written through the semantic API on a node.
Who can use it: Tracers can create and use ad-hoc calculated fields inside a Discover exploration. Weavers (and above) can persist calculated fields onto a node.

Celiq has two distinct calculated-field mechanisms. They look similar but live in different places and behave differently. This page explains both so you pick the right one and know where each value comes from.

Overview

A calculated field takes an expression like [revenue] / [orders], substitutes the values of the referenced fields, and evaluates simple arithmetic to produce a new number. The reference syntax is square brackets around a field name, and the supported operators are +, -, *, /, and parentheses.

The two mechanisms are:

MechanismWhere it livesWho creates itPersisted?Cache impact
Node-persisted calculated fieldsA calculated_fields JSON array stored on the nodeWeaver and above (semantic API)Yes โ€” saved on the nodeSaving invalidates the query cache
Discover session calculated fieldsThe CALCULATED section of the Discover field panelAnyone using Discover (Tracer and above)No โ€” exists only for the current explorationNone โ€” computed in the browser at display time

Both produce extra numeric columns in your results. The difference is durability and scope: one is part of the model, the other is a throwaway helper for a single exploration.

When to use it

  • Use a Discover session calculated field when you are exploring and want a quick derived number โ€” a ratio, a difference, a per-unit value โ€” for this result set only. It is the fastest path and needs no modeling permissions.
  • Use a node-persisted calculated field when the derived value belongs to the data model itself and should travel with the node. Because it is stored on the node and clears the query cache on save, treat it as a modeling change, not an exploration tweak.
๐Ÿ“
Note

If a derived number is something the whole workspace should rely on and chart against, a modeled metric is usually the better home than either calculated-field mechanism. See Metrics.

Concepts

  • Expression โ€” the formula, e.g. [revenue] / [orders]. Field references use [field_name] and are replaced with the numeric value before evaluation.
  • Label โ€” the human-readable name shown as the column header (e.g. Revenue per Order).
  • Format โ€” how the value is displayed: Number, Currency ($), or Percent (%).
  • Selected vs defined โ€” in Discover you can define several calculated fields but only the ones you select (toggle on) are added to the result. Defining a field does not automatically add it to your output.
  • calculated_fields (node column) โ€” a JSONB array on the nodes table holding the persisted definitions for that node.

Getting started

Prerequisites
  • A connected warehouse and at least one domain and reveal you can explore (see Discover).
  • For node-persisted fields: a Weaver, or higher, role.
How to open it

For Discover session calculated fields, open Discover, choose a domain and reveal, and look at the field panel on the left. Below the dimensions and metrics you will see a CALCULATED section header (marked with an ฦ’ badge) and a count of how many calculated fields you have defined.

Node-persisted calculated fields are not authored through a screen in the field catalog โ€” there is no dedicated calculated-fields catalog tab. They are written by sending the definitions to the node via the semantic API.

Step-by-step

1

Open a Discover exploration

Go to Discover, pick your domain and reveal, and select the metrics and dimensions you want. Run the query so you can see the result columns you will reference.

2

Open the CALCULATED section

In the left field panel, scroll to the CALCULATED section header. Click + New calculated field to open the inline form.

3

Name it, write the expression, choose a format

Enter a Label (e.g. Revenue per Order), an expression (e.g. [revenue] / [orders]), and pick a Format โ€” Number, Currency ($), or Percent (%). The Save button stays disabled until both the label and expression are filled in.

4

Save and select it

Click Save. The field appears under the CALCULATED header with an ฦ’ badge. Click the row to toggle it on (selected). Only selected calculated fields are added to your results.

5

Re-run and read the new column

Run the query. Selected calculated fields are computed per row and appended as new columns using your chosen format. Edit (โœŽ) or delete (โœ•) a field at any time from its row.

For node-persisted calculated fields, a Weaver sends the full array of definitions for a node to PATCH /api/semantic/nodes/:id/calculated-fields. The body must contain a calculated_fields array; a non-array body is rejected with 400. On success the definitions are stored on the node and the query cache is invalidated so later queries reflect the change.

Examples

A Discover session calculated field for revenue per order, formatted as currency:

Discover calculated field (in the inline form)
{

"label": "Revenue per Order",

"expression": "[revenue] / [orders]",

"format": "currency"

}

How it evaluates per row: each [field] reference is replaced with that row's numeric value, then the arithmetic runs. A row with revenue = 12000 and orders = 300 yields 40, displayed as $40 under a Revenue per Order column.

A node-persisted set of calculated fields sent to the semantic API:

PATCH /api/semantic/nodes/:id/calculated-fields
{

"calculated_fields": [

{ "label": "Revenue per Order", "expression": "[revenue] / [orders]", "format": "currency" },

{ "label": "Return Rate", "expression": "[returns] / [orders]", "format": "percent" }

]

}
๐Ÿ“
Note

Discover session calculated fields are merged into your rows and columns at query time, in the browser โ€” they are not pushed down into warehouse SQL and are not stored anywhere. Close or change the exploration and they are gone unless you defined them again.

Best practices

  • Reference only fields present in the result. The expression evaluates against the current row; a referenced field that is not in the result resolves to 0.
  • Keep expressions arithmetic. Only digits, whitespace, and + - * / ( ) are allowed. Anything else (functions, text, comparisons) is rejected and the field shows no value.
  • Match the format to the meaning. Use Currency for money, Percent for ratios you want shown as a percentage, Number for plain counts and rates.
  • Prefer a metric for shared, durable logic. If many people need the same derived number across many charts, model it as a Metric instead of recreating a session field each time.
  • Treat node-persisted edits as modeling changes. Saving them clears the query cache for the workspace, so coordinate with other Weavers as you would any model change.

Tips

๐Ÿ’ก
Tip

Defining a calculated field in Discover is not the same as adding it. After you Save, click the row to select it (it gets a highlighted left border) โ€” only selected fields are appended to your results.

Common mistakes

โš ๏ธ
Warning
  • Expecting it in Context Studio. Neither mechanism is surfaced in Context Studio. Calculated fields are separate from node metrics and measures and do not appear there.
  • Looking for a calculated-fields catalog tab. There is none. Session fields live only in the Discover field panel; node-persisted fields live in the node's calculated_fields array.
  • Assuming session fields are saved. They are scoped to the exploration and are not persisted. Reopening Discover starts you with an empty CALCULATED section.
  • Using unsupported syntax. Text, function calls, or comparisons in the expression fail the safety check and produce no value.

Troubleshooting

SymptomCauseFix
Calculated field defined but no column appearsThe field is defined but not selectedClick the field row in the CALCULATED section to toggle it on, then re-run
The value comes out as 0 for a termA referenced [field] is not in the result, or its value is non-numericAdd the referenced field to the query, or reference a field that is actually returned
The column is empty / no value computesThe expression contains characters outside + - * / ( ) and digitsRewrite it as plain arithmetic over [field] references
Save button stays greyed outLabel or expression is blankFill in both the Label and the expression โ€” Save enables only when both are present
API returns calculated_fields must be an array (400)The PATCH body did not send calculated_fields as an arraySend the full set of definitions as a JSON array under calculated_fields
API returns Node not found (404)The node id in the URL does not exist in this workspaceUse a valid node id for the current workspace
New node-persisted values not reflected in a chartCached query resultsThey clear automatically on save (the cache is invalidated); re-run the query if you still see stale numbers