# Calculation Builder
> Reference for the no-code Calculation Builder: how to build each calculation in the UI and how common metric settings affect the result.
The Calculation Builder is the no-code interface for creating metrics while you build a report. Click a metric or column, pick what you want to compute, and Holistics builds it for you.
> New to building calculations? Start with the [Custom Calculations Handbook](/docs/guides/calculations) for a guided, task-by-task path. For opening the builder, browsing the catalog, creating with AI, and checking the generated AQL, see [Start building with Calculation Builder](/docs/calculation-builder/start-building).
## Common metric settings {#common-metric-settings}
Most metric calculations share a few settings. They do not change which calculation you are using; they control the scope, grain, and display of the result.
The same panel usually brings those settings together: the metric you are building from, any metric-level conditions, grouping for aggregation, and the display format.
| Setting | What it controls |
| --- | --- |
| Filter | Conditions that apply to this metric only. Use it to turn revenue into delivered revenue without filtering the whole report. |
| Grouping for aggregation | The grain where the metric is computed, also known as its [Level of Detail](/as-code/aql/learn/level-of-detail). Use it for totals beside detail rows, or nested metrics like average orders per customer. |
| Format | How the value displays, such as showing `0.124` as `12.4%`, abbreviating `1200` as `1.2K`, or displaying a ratio as currency. |
Use the default grouping when you want the metric to follow the report's dimensions. Change the grouping only when the metric needs a different grain from the table or chart around it.
## The calculation builders
Each metric calculation below shows what it does, how to build it in the UI, and where to go for the AQL reference behind it.
### Filtered metric {#filter}
**Scope a metric to a subset.** Start from any metric and add a condition so it measures only the rows you care about. A revenue metric filtered to delivered orders, for example, becomes a completed-revenue metric. The condition lives on the metric itself, so your other metrics stay untouched. (This is the metric-level filter under **Metric controls**, not the report-level Filter that narrows every metric on the report at once.)
To build it:
1. Start from any metric.
2. Open its menu and choose **Create metric from this → Metric controls → Filtered metric**.
3. Add a condition on a dimension (for example, an order status).
4. Rename the result so it reads clearly.
*Reference: [where](/reference/aql/where)*
### Arithmetic {#arithmetic}
**Combine two metrics with +, −, ×, or ÷.** Arithmetic turns two existing metrics into a new one, the usual source of copy-paste SQL. Divide is the one you reach for most: a ratio like average order value is one revenue metric divided by an order-count metric, defined once and correct at every grain the report uses.
To build it:
1. Open a metric's menu, choose **Arithmetic**, then the operator (**Add**, **Subtract**, **Multiply**, or **Divide**).
2. Pick the first metric (for a ratio, the numerator).
3. Pick the second metric (the denominator).
4. Format the result (for example, as currency).
*Reference: [operator](/reference/aql/operator)*
### Period over period {#period-over-period}
**Compare a metric across two time windows.** Period over period puts this period next to a past one without a self-join or a date spine. Point it at your date dimension, choose the comparison period, and pick the output you want.
To build it:
1. Click the metric you want to compare.
2. Choose **Period over period**.
3. Point it at your date dimension and choose a previous or dynamic period.
4. Pick the output: the display value, the absolute change, or the percent change.
*Reference: [time-intelligence-functions](/reference/aql/time-intelligence-functions)*
### Moving calculations {#moving-calculations}
**Recompute a metric over a sliding window.** A moving calculation runs a function over a window of rows around each point, then slides that window along. Averaging the window smooths a noisy trend, so a spiky week-to-week line resolves into a readable curve. Point a different function at the same window and it measures how the line moves instead of smoothing it: a moving standard deviation gauges volatility, a trailing sum gives a rolling total, and a moving min or max tracks running highs and lows.
To build it:
1. Click the metric on a time-based report.
2. Choose **Moving Calculation**.
3. Pick the function, the window shape, and (optionally) how the window is ordered, filtered, and grouped, as described below.
It behaves like a moving average by default, but the panel has more range than the name suggests. Three choices shape the result.
#### Pick the function
The window doesn't have to average. In **Moving Calculation** you can run Sum, Average, Min, Max, Count, standard deviation (sample or population), or variance (sample or population) over the same window, and each answers a different question:
- **Average** smooths the line into a trend. This is the default, shown above.
- **Sum** gives a rolling total over a fixed lookback, like trailing 4-week volume or a trailing-12-months figure.
- **Standard deviation or variance** turns the window into a volatility gauge that climbs when weekly orders get erratic and settles when they steady out.
- **Min or Max** tracks the running low or high across the window, the way you follow a high-water mark or a rolling floor.
So the same builder covers two jobs: smoothing a line (Average) and measuring how it moves (the rest).
#### Shape the window: trailing, centered, or leading
Two fields set the window. **Previous** counts rows behind the current row, and **Next** counts rows ahead. Their mix decides where the window sits relative to each point:
| Shape | Previous | Next | What it answers |
| --- | --- | --- | --- |
| Trailing | N | 0 | How have the last N periods been trending? (the classic moving average) |
| Centered | N | N | What is the smooth trend around this period? (symmetric, best for seeing shape) |
| Leading | 0 | N | What do the next N periods look like? |
A trailing window is what most people mean by a moving average: it only looks backward over the last N periods (past 7 days, past 3 weeks, and so on), so it never borrows from the future. A centered window smooths most cleanly because it balances both sides, which is why it makes such a good hero line drawn over the raw data. A leading window points the other way, summarizing what is still ahead.
#### Order, filter, and group the window
A few more options control what the window slides over:
- **Order values by**: the sequence the window follows. Leave it on **Rows** to slide along the report's own order (your weeks, top to bottom), and use the sort toggle to flip the direction.
- **Null if not enough values**: near the edges of the data a full window doesn't exist yet. Leave this off and Holistics uses whatever rows are available. Turn it on to blank out those early rows so a partial window never reads as a real value.
- **Filter**: add **Conditions** that apply to this calculation only, so the window runs over a subset (a moving average of just delivered orders, for instance) without changing any other metric.
- **Group by**: set the **Grouping for aggregation**, which is the window's [Level of Detail](/as-code/aql/learn/level-of-detail). It decides which dimensions the window runs within. Break weekly orders down by country and grouping keeps each country's window separate, so one country's spike never leaks into another's average. Choose **Group by all explore dimensions except** to inherit the report's dimensions (optionally dropping a few), or **Group only by** to name the grouping yourself.
*Reference: [window-function](/reference/aql/window-function)*
### Running total {#running-total}
**Accumulate a metric along a date.** Where a moving calculation slides a fixed-width window, a running total keeps adding as it goes, accumulating a metric (sum, average, min, or max) along a date dimension. It turns daily new users into cumulative users to date, or monthly revenue into revenue so far.
To build it:
1. Click the metric.
2. Choose **Running total**.
3. Pick the date dimension to accumulate along.
4. Read the cumulative value building up period by period.
*Reference: [running_total](/reference/aql/running_total)*
### Percent of total {#percent-of-total}
**Show each part against the whole.** Percent of total divides a metric by its total and handles the dimension context for you, so revenue by category reads as a share instead of a raw number. The interesting part is the word "total": in a table with more than one dimension, there is more than one total a value could be measured against, and the metric's **Total Value** setting is where you pick which one.
To build it:
1. Click the metric.
2. Choose **Percent of total**.
3. Pick the **Total Value** (the choices depend on the table type, below).
4. Format the result as a percent.
Take orders by quarter and continent. The single cell for Asia in 2026 Q2 (3,673 orders) reads three different ways depending on the total you choose:
- Against the **grand total** of every order (33,010): **11.13%**.
- Against **Asia's** column total (15,273): **24.05%**.
- Against **2026 Q2's** row total (7,948): **46.21%**.
Same number, three stories. Which one is right depends on the question you're asking, so the builder lets you say.
#### Example: percent of total in a pivot table {#in-a-pivot-table-row-column-or-grand-total}
A pivot has a clear row axis and column axis, so Percent of Total (PoT) offers all three Total Value choices: **Row Total**, **Column Total**, and **Grand Total**. The setting is the denominator switch.
Start with this raw-count pivot. The examples below use the same numbers all the way through:
| Orders | Africa | Asia | Europe | North America | Oceania | South America | Total |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026 Q1 | 520 | 3,200 | 1,400 | 1,600 | 310 | 570 | 7,600 |
| 2026 Q2 | 640 | 3,673 | 1,450 | 1,320 | 355 | 510 | 7,948 |
| 2026 Q3 | 710 | 4,300 | 1,500 | 1,650 | 360 | 480 | 9,000 |
| 2026 Q4 | 600 | 4,100 | 1,380 | 1,480 | 322 | 580 | 8,462 |
| Total | 2,470 | 15,273 | 5,730 | 6,050 | 1,347 | 2,140 | 33,010 |
The cell value stays the same: **Asia in 2026 Q2 = 3,673 orders**. Total Value only changes which total becomes the denominator.
##### Row Total
**Use Row Total when you want each row to add up to 100%.** For each time period (row), Holistics divides every continent by that row's total. In this example, **2026 Q2** is the row in focus, so every continent is divided by the 2026 Q2 total: 7,948 orders.
| 2026 Q2 example | Raw orders | Calculation | Percent of row |
| --- | ---: | --- | ---: |
| Africa in **2026 Q2** | 640 | 640 / 7,948 | 8.05% |
| Asia in **2026 Q2** | 3,673 | 3,673 / 7,948 | **46.21%** |
| Europe in **2026 Q2** | 1,450 | 1,450 / 7,948 | 18.24% |
| North America in **2026 Q2** | 1,320 | 1,320 / 7,948 | 16.61% |
| Oceania in **2026 Q2** | 355 | 355 / 7,948 | 4.47% |
| South America in **2026 Q2** | 510 | 510 / 7,948 | 6.42% |
| **2026 Q2 Total** | 7,948 | 7,948 / 7,948 | 100.00% |
The final pivot looks like this. Each row's **Total PoT** is 100% because every cell is divided by its own row total.
| Quarter | Africa orders | Africa PoT | Asia orders | Asia PoT | Europe orders | Europe PoT | North America orders | North America PoT | Oceania orders | Oceania PoT | South America orders | South America PoT | Total orders | Total PoT |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026 Q1 | 520 | 6.84% | 3,200 | 42.11% | 1,400 | 18.42% | 1,600 | 21.05% | 310 | 4.08% | 570 | 7.50% | 7,600 | 100.00% |
| 2026 Q2 | 640 | 8.05% | 3,673 | **46.21%** | 1,450 | 18.24% | 1,320 | 16.61% | 355 | 4.47% | 510 | 6.42% | 7,948 | 100.00% |
| 2026 Q3 | 710 | 7.89% | 4,300 | 47.78% | 1,500 | 16.67% | 1,650 | 18.33% | 360 | 4.00% | 480 | 5.33% | 9,000 | 100.00% |
| 2026 Q4 | 600 | 7.09% | 4,100 | 48.45% | 1,380 | 16.31% | 1,480 | 17.49% | 322 | 3.81% | 580 | 6.85% | 8,462 | 100.00% |
| Total | 2,470 | 7.48% | 15,273 | 46.27% | 5,730 | 17.36% | 6,050 | 18.33% | 1,347 | 4.08% | 2,140 | 6.48% | 33,010 | 100.00% |
This answers: "Within 2026 Q2, how much did each continent contribute?"
##### Column Total
**Use Column Total when you want each column to add up to 100%.** For each continent (column), Holistics divides every time period by that column's total. In this example, **Asia** is the column in focus, so every quarter is divided by the Asia total: 15,273 orders.
| Asia orders | Raw orders | Calculation | Percent of column |
| --- | ---: | --- | ---: |
| **Asia** in 2026 Q1 | 3,200 | 3,200 / 15,273 | 20.95% |
| **Asia** in 2026 Q2 | 3,673 | 3,673 / 15,273 | **24.05%** |
| **Asia** in 2026 Q3 | 4,300 | 4,300 / 15,273 | 28.15% |
| **Asia** in 2026 Q4 | 4,100 | 4,100 / 15,273 | 26.84% |
| **Asia Total** | 15,273 | 15,273 / 15,273 | 100.00% |
The final pivot looks like this. Each continent's **Total PoT** is 100% because every cell is divided by its own column total.
| Quarter | Africa orders | Africa PoT | Asia orders | Asia PoT | Europe orders | Europe PoT | North America orders | North America PoT | Oceania orders | Oceania PoT | South America orders | South America PoT | Total orders | Total PoT |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026 Q1 | 520 | 21.05% | 3,200 | 20.95% | 1,400 | 24.43% | 1,600 | 26.45% | 310 | 23.01% | 570 | 26.64% | 7,600 | 23.02% |
| 2026 Q2 | 640 | 25.91% | 3,673 | **24.05%** | 1,450 | 25.31% | 1,320 | 21.82% | 355 | 26.35% | 510 | 23.83% | 7,948 | 24.08% |
| 2026 Q3 | 710 | 28.74% | 4,300 | 28.15% | 1,500 | 26.18% | 1,650 | 27.27% | 360 | 26.73% | 480 | 22.43% | 9,000 | 27.26% |
| 2026 Q4 | 600 | 24.29% | 4,100 | 26.84% | 1,380 | 24.08% | 1,480 | 24.46% | 322 | 23.90% | 580 | 27.10% | 8,462 | 25.63% |
| Total | 2,470 | 100.00% | 15,273 | 100.00% | 5,730 | 100.00% | 6,050 | 100.00% | 1,347 | 100.00% | 2,140 | 100.00% | 33,010 | 100.00% |
This answers: "Within Asia, how much did each quarter contribute?"
##### Grand Total
**Use Grand Total when you want the whole pivot to add up to 100%.** Every cell is divided by the same denominator: 33,010 orders.
| Cell | Raw orders | Calculation | Percent of grand total |
| --- | ---: | --- | ---: |
| Asia in 2026 Q2 | 3,673 | 3,673 / 33,010 | **11.13%** |
| Europe in 2026 Q2 | 1,450 | 1,450 / 33,010 | 4.39% |
| All continents in 2026 Q2 | 7,948 | 7,948 / 33,010 | 24.08% |
| Asia across all quarters | 15,273 | 15,273 / 33,010 | 46.27% |
| Grand Total | 33,010 | 33,010 / 33,010 | 100.00% |
The final pivot looks like this. Only the bottom-right **Total PoT** is 100% because every cell is divided by the same grand total.
| Quarter | Africa orders | Africa PoT | Asia orders | Asia PoT | Europe orders | Europe PoT | North America orders | North America PoT | Oceania orders | Oceania PoT | South America orders | South America PoT | Total orders | Total PoT |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026 Q1 | 520 | 1.58% | 3,200 | 9.69% | 1,400 | 4.24% | 1,600 | 4.85% | 310 | 0.94% | 570 | 1.73% | 7,600 | 23.02% |
| 2026 Q2 | 640 | 1.94% | 3,673 | **11.13%** | 1,450 | 4.39% | 1,320 | 4.00% | 355 | 1.08% | 510 | 1.54% | 7,948 | 24.08% |
| 2026 Q3 | 710 | 2.15% | 4,300 | 13.03% | 1,500 | 4.54% | 1,650 | 5.00% | 360 | 1.09% | 480 | 1.45% | 9,000 | 27.26% |
| 2026 Q4 | 600 | 1.82% | 4,100 | 12.42% | 1,380 | 4.18% | 1,480 | 4.48% | 322 | 0.98% | 580 | 1.76% | 8,462 | 25.63% |
| Total | 2,470 | 7.48% | 15,273 | 46.27% | 5,730 | 17.36% | 6,050 | 18.33% | 1,347 | 4.08% | 2,140 | 6.48% | 33,010 | 100.00% |
This answers: "Out of everything in this pivot, how much did this cell or subtotal contribute?"
#### In a flat table: grand total or a custom scope
A flat table has no separate row and column axes, so the presets collapse to two: **Grand Total** (divide by the total across every dimension in the table) and **Custom**, where you name the scope yourself.
Custom shows a checkbox for each dimension under "Calculate the total of all values across". Checking a dimension tells the metric to total over all of its values, so that dimension drops out of the denominator. Check **Continent Name** only, and every continent's percentage is measured within its own quarter (the quarter stays fixed, the continent is totalled away). It's the flat-table way of expressing the same choice the pivot makes with Row and Column Total: you're deciding which dimensions define "the whole".
*Reference: [percent_of_total](/reference/aql/percent_of_total)*
### Case when {#case-when}
**Bucket values into tiers.** Case when returns a value based on the first condition that matches, which is how you turn a continuous field into tiers (for example, bucketing customers into age or spend bands). The result is a dimension (a bucketed field), not a metric.
To build it:
1. Open the calculation menu and choose **Case when**.
2. Add a condition and the value it should return.
3. Add more conditions, one per tier (age group, spend band, and so on).
4. Set a default value for anything that doesn't match.
*Reference: [case-when](/reference/aql/logical-functions#case-when)*
## Related
- [Start building with Calculation Builder](/docs/calculation-builder/start-building): how to open the builder, browse available calculations, create with AI, and inspect generated AQL.
- [Custom Calculations Handbook](/docs/guides/calculations): the guided, task-by-task path to building calculations.
- [Ad-hoc Fields](/docs/ad-hoc-fields): where calculation fields live and how they differ from dataset fields.
- [AQL](/as-code/aql): the query language every calculation generates.
- [Level of Detail (AQL)](/as-code/aql/learn/level-of-detail): the concept and functions behind metric grouping.
- [Nested aggregation](/as-code/aql/learn/nested-aggregation): the AQL pattern for an aggregate of an aggregate.