Skip to main content

Window calculations

Window calculations rank, accumulate, or smooth values across related rows.

Rank

Assigns a rank to each record based on the order of specified fields, optionally within partitions.

rank calculation

Inputs

InputRequired?Description
Ranking modeYesHow ties are numbered:
  • Rank: ties share a rank; the next rank skips (e.g. 1, 1, 3, 4, 4, 6, ...).
  • Dense Rank: ties share a rank; the next rank is consecutive (e.g. 1, 1, 2, 3, 3, 4, ...).
Ranking byYesOne or more fields to sort by, each ascending or descending.
Ranking withinNoRestart the ranking within each group (partition).

Use cases

  • Rank products by total sales
  • Top customers by revenue within each region
  • Leaderboard of support agents by tickets closed

Running total

Calculates a running sum, average, min, or max of a metric along a date dimension on the viz.

Note: To run along a non-date dimension, switch to Formula mode and use running_total.

running total calculation

Inputs

InputRequired?Description
FieldYesThe metric (or dimension) to accumulate along the date dimension on the viz.
Dimension aggregationYes (when Field is a dimension)How to aggregate the dimension before running (e.g. Count, Sum).

Use cases

  • Cumulative total users over time
  • Year-to-date revenue by quarter
  • Running count of orders since launch

Moving calculations

Calculate a moving calculation on a metric.

moving average calculationmoving sum calculation

Inputs

InputRequired?Description
Moving CalculationYesThe function over the window (full list):
  • Average: smooth a noisy trend (classic moving average).
  • Sum: rolling total over a fixed lookback.
  • Min / Max: running low or high in the window.
  • Count: how many values fall in the window.
  • Sample standard deviation / Population standard deviation: how spread out values are in the window.
  • Sample variance / Population variance: squared spread in the window.
ValuesYesThe metric to compute over the moving window.
Order values byYesThe direction the window slides. Only options that fit the current viz are shown:
  • Rows: table; pivot table
  • Columns: pivot table
  • X-Axis: line chart family, when an X-axis field is on the viz
  • Legend: line chart family, when a legend/series field is on the viz
  • Custom: pick dimensions to define the move direction
    • Table with more than one dimension
    • Pivot table with more than one row/column dimension
Number of valuesYesWindow size as Previous (behind) and Next (ahead), plus the current value:
  • Trailing (e.g. Previous 6, Next 0): last N periods including today.
  • Centered (e.g. Previous 3, Next 3): look both ways.
  • Leading (e.g. Previous 0, Next 6): upcoming values only.
Null if not enough valuesNoWhat to do when the window is incomplete (start/end of the series):
  • Checked: return null until the window is full.
  • Unchecked: use a partial window with the values that exist.

Use cases

  • 7-day moving average of orders
  • Rolling 4-week revenue sum
  • Moving max of daily active users over the last 14 days

Open Markdown
Let us know what you think about this document :)