01 / 20

Table Calculations
Running Totals & Averages

Master running totals, moving averages, and percent of total to unlock powerful analytical insights directly within Tableau.

Tableau

What Are Table Calculations?

Table calculations are computations that Tableau performs after the initial query results are returned. Unlike regular aggregations (SUM, AVG) that happen at the database level, table calculations transform the values already in the view: they can reference previous rows, subsequent rows, or the entire partition of data.

Why Table Calculations Matter

★ No Data Source Changes
Perform complex analytics without modifying your underlying data or writing SQL.
★ Dynamic Context
Results automatically update as you filter, sort, or restructure the visualization.
★ Row-to-Row Logic
Reference previous or next values: running sums, differences, percentages, and moving windows.

The Three Core Calculations

Running Total
Cumulative sum across rows: each cell equals the sum of all values from the first row to the current row.
Moving Average
Average over a sliding window of \(k\) rows: smooths fluctuations to reveal trends.
Percent of Total
Each value expressed as a fraction of the partition total: \(\frac{\text{value}}{\text{total}} \times 100\%\).

Running Total: The Formula

// Tableau Quick Table Calc
RUNNING_SUM(SUM([Sales]))

// Equivalent manual formula
WINDOW_SUM(SUM([Sales]), FIRST(), 0)
100 150 200 80 120 Monthly Sales 100 250 450 530 650 Running Total

Moving Average: The Formula

// 3-period moving average in Tableau
WINDOW_AVG(SUM([Sales]), -2, 0)

// -2 means "start 2 rows before current"
// 0 means "end at current row"
Raw Values vs. 3-Period Moving Average 100 150 200 80 120 180 150 143 133 127 Raw 3-Period MA

Percent of Total: The Formula

// Tableau formula
SUM([Sales]) / TOTAL(SUM([Sales]))

// Or use Quick Table Calculation:
// Right-click measure → Quick Table Calc → Percent of Total
Sales by Region: Percent of Total East 35% West 25% South 20% North 20% Total = $140K → Each segment = region / $140K $49K / $140K $35K / $140K $28K / $140K $28K / $140K

Addressing vs. Partitioning

Every table calculation in Tableau has two critical settings that control how the calculation traverses the data. Understanding them is essential to getting correct results.

Addressing (Direction)
The dimension(s) the calculation moves along: row by row, column by column, or across panes. This is the "compute using" setting.
Partitioning (Grouping)
The dimension(s) that define independent groups. The calculation resets at each partition boundary.

How to Apply Table Calculations

1
Build the base view: Drag your dimensions and measure onto the sheet. Verify the underlying aggregation (SUM, AVG, etc.) is correct.
2
Add the table calculation: Right-click the measure pill → Add Table Calculation, or use the Quick Table Calculation shortcut for common types.
3
Set the Compute Using: Choose Table (Across), Table (Down), or specific fields. This controls the addressing direction.
4
Verify with a reference table: Show the underlying data or add a text table to confirm the calculation produces expected values at each row.
5
Format and finalize: Apply number formatting (%, currency), add labels, and test with filters to ensure the calculation scope is correct.

Example 1: Running Total of Sales

A retail store tracks monthly sales. We want the cumulative total across all months to track progress toward an annual goal.

Month Sales Running Total Calculation
Jan $12K $12K \(12\)
Feb $18K $30K \(12 + 18\)
Mar $15K $45K \(30 + 15\)
Apr $22K $67K \(45 + 22\)
May $20K $87K \(67 + 20\)
RUNNING_SUM(SUM([Sales])) // Compute Using: Table (Across)

Example 2: 3-Month Moving Average

Using the same sales data, compute a 3-month moving average to smooth out monthly fluctuations and identify the underlying trend.

Month Sales 3-Mo MA Calculation
Jan $12K N/A Not enough data
Feb $18K N/A Not enough data
Mar $15K $15K \(\frac{12+18+15}{3}\)
Apr $22K $18.3K \(\frac{18+15+22}{3}\)
May $20K $19K \(\frac{15+22+20}{3}\)
WINDOW_AVG(SUM([Sales]), -2, 0) // Window: current + 2 previous

Example 3: Percent of Total by Region

Four sales regions contribute to a company total. We want to express each region's sales as a percentage of the grand total.

Region Sales % of Total Calculation
East $49K 35.0% \(\frac{49}{140} \times 100\)
West $35K 25.0% \(\frac{35}{140} \times 100\)
South $28K 20.0% \(\frac{28}{140} \times 100\)
North $28K 20.0% \(\frac{28}{140} \times 100\)
Total $140K 100%
SUM([Sales]) / TOTAL(SUM([Sales])) // Format as %

Combining Calculations: Running % of Total

You can nest table calculations. A running percent of total shows the cumulative contribution as we move through categories, sorted by descending sales.

Region (sorted) Sales % of Total Running %
East $49K 35.0% 35.0%
West $35K 25.0% 60.0%
South $28K 20.0% 80.0%
North $28K 20.0% 100.0%

The Compute Using Menu

Tableau offers several Compute Using presets. Each changes the direction and scope of your table calculation.

Table (Across)
Compute left to right across columns. Resets at each row. Best for comparing across a single dimension.
Table (Down)
Compute top to bottom down rows. Resets at each column. Best for time-series running totals.
Table (Across then Down)
Compute across the first row, then continue to the next. Treats the entire table as one continuous stream.

Common Mistakes

✕ Wrong Compute Using
Leaving the default "Table (Across)" when you need "Table (Down)" for a time-based running total. Always verify direction after adding the calc.
✕ Filtering Too Early
Regular filters remove data before the table calc runs. This changes the total used in the calculation. To hide data without affecting the total, use a table calculation filter instead of a regular dimension filter.
✕ Ignoring NULLs
Missing data points can break moving averages. A 3-period window with a NULL in it may return NULL instead of averaging the available values. Use ZN() to handle NULLs.

Summary Comparison

Running Total Moving Average Percent of Total
Purpose Cumulative sum Smooth trends Show contribution
Formula \(\sum_{i=1}^{n} x_i\) \(\frac{1}{k}\sum x_i\) \(\frac{x_n}{\sum x} \times 100\)
Tableau Func. RUNNING_SUM WINDOW_AVG TOTAL
Best For YTD tracking Noisy time series Composition views
Resets At Partition boundary Partition boundary Partition boundary
Key Pitfall Wrong direction Window includes NULLs Filters exclude data

Question 1 of 5

Monthly sales are: $10K, $20K, $15K, $25K. What is the running total at month 3?

Question 2 of 5

Which Tableau function creates a 3-period moving average?

Question 3 of 5

Region A has sales of $60K and the total across all regions is $200K. What is Region A's percent of total?

Question 4 of 5

In Tableau, what does the partitioning field control in a table calculation?

Question 5 of 5

You apply a regular filter that removes Q1 data, then compute a percent of total for the remaining quarters. What happens?