Table Calculations
Running Totals & Averages
Master running totals, moving averages, and percent of total to unlock powerful analytical insights directly within 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
The Three Core Calculations
Running Total: The Formula
RUNNING_SUM(SUM([Sales]))
// Equivalent manual formula
WINDOW_SUM(SUM([Sales]), FIRST(), 0)
Moving Average: The Formula
WINDOW_AVG(SUM([Sales]), -2, 0)
// -2 means "start 2 rows before current"
// 0 means "end at current row"
Percent of Total: The Formula
SUM([Sales]) / TOTAL(SUM([Sales]))
// Or use Quick Table Calculation:
// Right-click measure → Quick Table Calc → Percent of Total
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.
How to Apply Table Calculations
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\) |
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}\) |
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% |
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.
Common Mistakes
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?