Skip to content

Chart calculations in the classic Workbook Editor

16 min read · Updated 26 Nov 2026

This page covers calculations you set on a chart measure in the classic Workbook Editor: running totals, moving averages, growth against an earlier period, ranks, shares of a total, calculations at a finer grain than the chart shows, and line chart forecasts. To keep a calculation like these as a governed measure that every chart and app reuses, define it in the semantic layer instead, as a time intelligence measure or a calculated measure.

A running total, for example, shows annual recurring revenue building up quarter by quarter:

Bar chart titled ARR Growth over time showing revenue accumulating quarter by quarter from 2021-1 to 2024-1, reaching $25.7M.

  1. Select the chart and open its Data tab. See Set an object up in the properties panel.
  2. Expand the measure.
  3. Choose a calculation from one of two drop-downs:
    • Advanced calculation for the calculations grouped under Moving Aggregations, Period over Period and Others.
    • Nested for a calculation over dimensions the chart does not show. See Nested calculations.
  4. Fill in the settings that appear below the drop-down. A red icon beside a setting means its value is not valid; hover over it for the reason.

A measure can use both drop-downs. To remove a calculation, choose None.

Most charts show both drop-downs on each measure. If a measure has neither, that measure does not support calculations; in some charts, such as a treemap or a waterfall, only the supporting measures offer them. Some charts offer only part of the list:

  • A table shows Advanced calculation only when its type is Table. An Expandable table or a Pivot table offers only Nested. See Tables.
  • A KPI has no dimensions, so it offers the nested calculations and the period-over-period Value, Difference, Rate, Growth, Annualized Period Growth and Compound Annual Growth Rate. To compare periods in a KPI, use a nested time dimension.

Moving aggregations combine each record with the records before it, or around it. Their Aggregation can be Sum (the default), Avg, Min or Max.

Calculation Returns
Running Total The aggregation of all records up to and including the current one, such as revenue to date.
Running Rate The running total divided by the measure’s total, so the last record reaches 100%.
Moving Calculation The aggregation over a window of records around the current one, such as a moving average.

Running Total and Running Rate have two more settings:

  • Dimensions: the dimensions the calculation restarts for. With none chosen, it restarts for each value of the chart’s second dimension, if the chart has one.
  • Order by: the order the records accumulate in, independent of the chart’s sorting.

Running Total settings with Aggregation Sum, a Dimensions selector showing Select dimensions, and an Order by button.

A running rate shows how fast a total builds up. This chart compares the share of each year’s revenue reached by each month:

Line chart of cumulative revenue share by month for 2022, 2023 and 2024, with 2024 rising fastest and reaching 100% by October.

Moving Calculation sets its window with two numbers, counted from the current record: negative numbers count records before it and positive numbers count records after it.

  • Periods before: the start of the window. The default is -6.
  • Periods after: the end of the window. The default is 0, the current record. It cannot be smaller than Periods before.
  • Null if there are not enough values: when ticked, records whose window is incomplete, near the start or end of the chart, show no value.

A six-month moving average smooths out seasonality and one-off spikes:

Line chart titled Monthly Active User Trend with 6 months moving avg, comparing Active Customers with a smoother moving average line.

With Aggregation Avg, Periods before -2, Periods after 0 and Null if there are not enough values ticked, each quarter shows the average of itself and the two quarters before it, and the first two quarters are empty:

Table of quarterly Revenue next to Revenue Moving Average, with dashes in the first two rows and averages from 2021-3 onward.

A period-over-period calculation compares each record with another record along the chart’s dimension. Compare with period sets how far away the comparison record is: -1, the default, is the previous record, and -4 with quarterly data is the same quarter a year earlier. A positive number compares with a later record. It must be a whole number and cannot be 0.

Calculation Returns
Value The comparison record’s value, such as the same quarter last year.
Difference current − comparison
Rate current / comparison. Empty when the comparison is 0.
Growth (current − comparison) / |comparison|
Correlation The correlation of period-over-period changes. See Correlations.
Accumulated Growth The growth of the measure’s running total against another measure’s running total.
Annualized Period Growth (current / comparison)n − 1, where n is Number of periods in a year.
Compound Annual Growth Rate (current / comparison)1/n − 1, where n is the number of periods back.

Growth divides by the absolute value of the comparison, so a rise is always positive, even from a negative value:

Table of Revenue by order quarter with a Revenue QoQ column showing growth percentages, with negative values such as -27% in red.

Accumulated Growth returns (running total of the measure − running total of the comparison measure) / |running total of the comparison measure|. Add the comparison measure under Compare Measure, which needs at least one dimension in the chart, and set the accumulation order with Order by, as for a running total. Use it, for example, to compare revenue to date this year with revenue to date last year.

Annualized Period Growth scales the growth between two periods to a year, so you can compare quarter-on-quarter or month-on-month growth with year-on-year growth. Set Number of periods in a year, for example 4 for quarters; it must be positive. Compare with period must be negative, and is usually -1: the formula does not adjust for a larger offset, so with quarters and -4 a ratio of 1.1 returns 46.41%, not 10%.

Compound Annual Growth Rate (CAGR) returns the average growth per period over several periods. n is the absolute value of Compare with period, which must be negative. With -2 and a ratio of 1.21, CAGR is 10%.

Compare periods without a date in the chart

Section titled “Compare periods without a date in the chart”

To show a period-over-period result in a chart that has no date dimension, such as year-on-year growth in a KPI or for each country in a bar chart, turn on Nested time dimension under the calculation. It is available for Value, Difference, Rate, Growth, Annualized Period Growth and Compound Annual Growth Rate.

The time dimension then comes from a date filter inside the measure’s own definition, so the measure must be a custom calculation that filters a date field in one of two ways:

  • With a predefined period filter, such as current year to date, the comparison steps by that period, and Compare with period sets how many periods back.

    Measure Sum of Sales Data Sales Amount filtered by Predefined Periods Flags Order Date New with predefined period Current YTD.

  • With a date range filter, for example between two dates viewers can change, choose the step in Time period: Year, Quarter, Month, Week or Day.

    Sum of Sales Amount measure filtered on Order Date New: at least parameter start_date (2023-01-01) and at most end_date (2023-12-31).

Growth calculation with Compare with period 1, Nested time dimension switched on, and the Time period drop-down listing Year, Quarter, Month, Week and Day.

The calculations under Others compare each value with the rest of the chart. Each has a Dimensions setting: choose dimensions to rank or total within each of their values, or none to work across all rows.

Rank returns the position of each value.

  • Order: Asc, the default, ranks the lowest value first; Desc ranks the highest first.
  • Dense: when ticked, tied values share a rank and the next value takes the next rank, so ranks 2, 2, 3. When cleared, the next value skips the ranks the tie used, so ranks 2, 2, 4.

Rank settings with Order Desc, Dense ticked, and the Dimensions drop-down open with Customer Country ticked and Occupation not ticked.

This table ranks revenue across all rows, and again within each country:

Table of Occupation, Customer Country and Revenue with a Total rank column across all rows and a Country Rank column restarting per country.

Total returns the measure’s total for the chosen dimensions on every row. Aggregation can be Sum, Avg, Min, Max, Percentile (see Percentiles) or Control value, which returns the average plus the number of Standard deviations you enter.

Table of Revenue by country and occupation with Revenue Grand Total 11,038,845 on every row and Country Avg Revenue per country.

Compare to Total compares each value with that total. Type of comparison sets how:

  • Rate, the default: value / total, such as a share of the sum.
  • Difference: value − total, such as the difference from the average.
  • Growth: (value − total) / |total|, such as the growth over the average.

Its Aggregation can be Sum, Avg, Min, Max, Percentile or Outliers. Outliers always uses Difference: it returns how far a value lies outside the average plus or minus the Standard deviations you enter, which must be more than 0, and 0 for a value inside that band.

Compare to Total settings with Type of comparison Rate, Aggregation Sum and an empty Dimensions selector.

This table shows each occupation’s share of its country’s revenue, the country average, and the difference and growth against that average:

Table of Australia and Canada rows by occupation with Revenue, Share of Revenue, Country Avg Revenue, Difference from Avg and Growth vs Avg columns.

To index every value against one point on the chart’s first dimension, turn on Index chart settings. Enter that point in Index Base Value, for example a year or a region, and the scale in Index Scale, which defaults to 100. With Rate, the base point then shows as 100 and every other value relative to it.

When Aggregation is Percentile, in Total, Compare to Total or a nested Calculation, three more settings appear:

  • Percentile value: the percentile to return, between 0 and 1. 0.5 returns the median.
  • Continuous: when off, the result is a value that occurs in the data. When on, it is interpolated between values, so it usually does not occur in the data.
  • Approx: when on, the database’s approximate percentile function is used, which is faster on large data but not exact.

A nested calculation works out the measure over extra dimensions that only this measure uses, then aggregates the result to the chart’s rows. For example, a table of revenue by country and occupation can show each row’s average monthly revenue without a month dimension. Choose the type from the measure’s Nested drop-down:

Nested drop-down open, listing None, Calculation (ticked), Ratio, Correlation and, under a UDF heading, UDF.

Type Returns
Calculation The measure for each combination of the extra dimensions, then aggregated, such as average daily users.
Ratio The measure aggregated at one grain divided by the measure aggregated at another.
Correlation The correlation between two dimensions for one measure, or between two measures. See Correlations.
UDF The result of a function in your database, applied to the measure’s values.
  • Aggregation: how the inner results combine for each chart row: Sum, Avg, Min, Max or Percentile (see Percentiles).

  • Additional Dimensions: the dimensions the measure is first calculated for.

  • Output type:

    • Default: the aggregated value.
    • Dimension value: the value of the additional dimension at the bottom or top result instead of a number, such as the month in which revenue was lowest. Set Position to Bottom or Top.
    • Value in a series: the first or last value of the inner series, transformed by Function. Set Position to First or Last. Percent rank returns its percent rank within the series, and Standard score returns how many standard deviations it lies from the series mean. Add the dimensions that order the series under Series Dimensions.

    Output type set to Value in a series, with Position First and Function Percent rank.

Nested Calculation settings with Aggregation Avg, Additional Dimensions Month Year and Output type Default.

With these settings, each row of the country and occupation table shows its average monthly revenue:

Customer Sales Comparison table of Sales Country and Occupation with an Avg Monthly Revenue column, such as $96,201.3 for Australia Professional.

Divides the measure aggregated over one set of dimensions by the measure aggregated over another. For example, the stickiness of a product is average daily active users divided by monthly active users.

  • Aggregation and Additional Dimensions: the numerator.
  • Bottom Aggregation and Bottom Dimensions: the denominator. Bottom Aggregation can be Sum, Avg, Min or Max.

The ratio returns nothing until both Additional Dimensions and Bottom Dimensions have at least one dimension.

Line chart titled Nested Ratio showing daily to monthly active users, with Nested Ratio, Aggregation Avg over Order Date New and Bottom Aggregation Max over Month Year in the properties panel.

UDF applies a user-defined function from your database to the measure’s values. It appears in the Nested drop-down only when user-defined functions are enabled for your account and at least one function is registered in the semantic layer.

  • Select UDF: the function.
  • One setting for each of the function’s parameters, labelled with its name and data type. For a parameter that takes the measure’s values as an array, add the dimensions to collect them by under Select Additional Dimension. For any other parameter, enter a value or pick a variable.
  • Output type: the same options as for Calculation.

UDF settings with Select UDF Percentile Exec, a data float parameter with Order Date New under Select Additional Dimension, q float 0.95 and Output type Default.

This Snowflake function, used in the example above, takes an array of values and a percentile and returns one number. It calculates the percentile from the exclusive rank q × (n + 1), where n is the number of values, and returns NULL when that rank is less than 1 or at least n. Despite its name, it does not match Excel’s PERCENTILE.INC:

CREATE OR REPLACE FUNCTION DEMO_DATASET.PUBLIC.PERCENTILE_EXCEL("DATA" ARRAY, "Q" FLOAT)
RETURNS FLOAT
LANGUAGE SQL
AS '
CASE
WHEN ARRAY_SIZE(data) = 0 THEN NULL
WHEN q * (ARRAY_SIZE(data) + 1) - 1 < 0
OR FLOOR(q * (ARRAY_SIZE(data) + 1) - 1) >= ARRAY_SIZE(data) - 1 THEN NULL
ELSE
ARRAY_SORT(data)[FLOOR(q * (ARRAY_SIZE(data) + 1) - 1)::INT] +
(ARRAY_SORT(data)[FLOOR(q * (ARRAY_SIZE(data) + 1) - 1)::INT + 1] -
ARRAY_SORT(data)[FLOOR(q * (ARRAY_SIZE(data) + 1) - 1)::INT]) *
(q * (ARRAY_SIZE(data) + 1) - 1 - FLOOR(q * (ARRAY_SIZE(data) + 1) - 1))
END';

Two calculations return a correlation coefficient:

  • Period-over-period Correlation, under Advanced calculation, correlates the measure’s period-over-period changes, typically in a heat map or correlation matrix. Add the dimensions to correlate over, usually including a date, under Additional Dimensions, set Compare with period, and choose a Comparison type: Absolute (the difference between the two values), Percentage (the default, the rate of change) or Natural log.
  • Nested Correlation correlates two dimensions for one measure, such as a correlation matrix of product categories, or two measures along one dimension. Add the dimension that pairs the values, usually a date, under Additional Dimensions. For two measures, add the second under Compare Measure, which needs at least one dimension in the chart.

Line chart titled Sales and Gross profit correlation over time, with the correlation swinging between about -93% and 60%.

Correlation settings with Date under Additional Dimensions, Compare with period -1 and Comparison type Percentage.

Heat map of sales correlation between product subcategories, with percentage values from about 65% to 95% in each cell.

Either correlation can compare two date ranges instead of consecutive records. Turn on Ranges comparison, set Start and End under Range and under Comparison Range, and choose a Comparison type: Absolute returns the difference between the two results and Percentage the percentage change. Each date can be fixed or come from a variable, so viewers can change the ranges.

Ranges comparison switched on, with Range 2025-01-01 to 2025-04-29, Comparison Range 2024-01-01 to 2024-04-29, and Comparison type Percentage.

A line chart can extend a measure past its last data point. The Forecasting section appears in the line chart’s Data tab only when the chart has exactly one dimension and that dimension is a date, not a date part. While a forecast is on, the chart’s sorting is disabled. A change that breaks these conditions, such as adding a second dimension, removes the chart’s forecasts.

  1. In Forecasting, add a forecast and pick the measure. You can add more than one.
  2. Choose the forecast type:
    • Linear fits a straight line through the data and continues it. It suits a measure that rises or falls by a roughly constant amount per point.
    • Exponential fits a curve and continues it. It suits a measure that grows or shrinks by a roughly constant percentage per point. It cannot fit data with zero or negative values.
    • Growth Scenarios (%) grows the last value by a rate you set, instead of following the trend. See Growth scenarios.
  3. For Linear and Exponential, choose which points to fit: All data, or Custom range to fit only the most recent points, set in Reference Points.
  4. Set Forecasted points, how many points to add after the last one. The default is 5.
  5. Optionally, enter a Label, and change the line style, width and color. By default the forecast is a dashed line in a lighter shade of the measure’s color.

Show reference line, on by default, draws a vertical line where the forecast starts. It is set on the first forecast, which also holds its Reference label.

Forecasting section with Sales, Linear, All data, Forecasted points 5, a dashed 2 px line in an inherited color, and Show reference line ticked.

Line chart of Sales and Margin over time with a dashed forecast continuing the Sales line upward past a vertical reference line.

An Exponential forecast curves instead of running straight:

Line chart of Sales, Margin and Forecast with a dashed Forecast line rising steeply after the vertical reference line.

A Growth Scenarios (%) forecast compounds a growth rate from the last data point, such as a plan for 10% growth a year. Enter the rate per period in Expected Growth (default 10%) and set Points per period, how many data points make up one growth period (default 1). For example, $10,000 growing at 10% a year for 3 years becomes $13,310. A point part-way through a period gets the matching share of that period’s compounded growth.

Each data point is Points per period
One day 7 for a week, about 30 for a month, about 365 for a year
One month 3 for a quarter, 12 for a year

Forecasting section with Sales, Growth Scenarios (%), Label Forecast, Forecasted points 10, Points per period 1 and Expected Growth 10%.

For the rest of the line chart’s settings, see Charts.

Business questions offer the same calculations as governed definitions. Running totals, moving calculations, ranks, totals and comparisons with a total or with another row are calculations over the answer. Nested calculations correspond to computing a measure at a finer grain, and period-over-period comparisons without a date in the answer use period axes.