Skip to content
Module 08 of 1250 min readMixed

Table calculations — running totals, ranks, percent of

WINDOW_SUM, RUNNING_AVG, RANK, PERCENT_FROM, the addressing/partitioning that determines what 'previous' means.

67%

Listen along

Read “Table calculations — running totals, ranks, percent of” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Learning objectives

By the end of this module, you should be able to:

  • 01Apply table calculations for running totals, ranks, and percentages
  • 02Control addressing and partitioning to make calcs do the right thing
  • 03Distinguish quick table calculations from custom ones

Table calculations operate on the table of values already aggregated and rendered on the view. WINDOW_SUM, RUNNING_AVG, RANK, PERCENT_FROM, LOOKUP — these compute relative to other cells in the table. They are different from regular aggregations in that they happen after the aggregation phase, not before.

Quick table calcs

Right-click any measure on the view → Quick Table Calculation → choose from Running Total, Percent of Total, Rank, Percentile, Moving Average, YoY Growth, Compound Growth Rate, Year-over-Year Growth, etc. These cover 80% of common needs without writing a custom calc.

Addressing and partitioning

Every table calc has a direction (addressing) and a scope (partitioning). Right-click → Compute Using → reveals the options. Examples:

  • Compute using Table (down): running total cumulates down the rows.
  • Compute using Table (across): cumulates across columns.
  • Compute using Pane (down): cumulates within each subgroup separately. Most common for grouped data.
  • Compute using a specific dimension: e.g., compute using Date — running total accumulates by date, partitioned by everything else.

The 'why does my YoY look wrong' moment

Most YoY bugs come from wrong addressing. If you have Region and Year on Columns and you compute YoY 'Table (across)', it cumulates across all the cells in the row — including across regions. The fix: 'Compute Using → Year' makes it cumulate by year, with Region as the partition. Right answer, right partition.

Custom table calculations

text
// YoY growth — explicit form
YoY = (SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / LOOKUP(SUM([Sales]), -1)
// Moving average — 3 periods
3-period MA = WINDOW_AVG(SUM([Sales]), -2, 0)
// Rank by sales, descending
Rank = RANK(SUM([Sales]), 'desc')
The three custom table calcs you'll see most often. Each requires setting addressing/partitioning correctly to mean what you intended.

Exercise

Build a view with Date on Columns and three regions as separate lines. Add a YoY growth rate as a table calc. Test: 'Compute Using → Table' vs 'Compute Using → Date'. Which produces YoY within each region (correct) vs YoY across regions (wrong)?

Key takeaways

  • Table calculations compute over the table after aggregation — not before.
  • Addressing = direction of computation; partitioning = scope of the computation.
  • Quick table calcs are pre-baked; the customisation panel exposes the real power.
Loading progress…
LeadAfrikPublic Economics Hub