Tableau Course
Table Calculations
Table calculations run after Tableau has already aggregated and laid out the marks in the view — they compute values across the existing marks rather than against the raw data. Running totals, percent of total, rank, and moving averages are all table calculations.
Table Calculations vs Regular Calculated Fields
Adding a Quick Table Calculation
The fastest way to apply a table calculation is the Quick Table Calculation menu. Right-click any Measure pill in the view — on Rows, Columns, or the Marks card — and select Quick Table Calculation. The sub-menu lists eight options. Tableau applies the calculation instantly and marks the pill with a delta symbol to indicate a table calculation is active.
| Quick Table Calculation | Computes | Common Use |
|---|---|---|
| Running Total | Cumulative sum of marks from first to current | Year-to-date revenue, cumulative orders |
| Difference From | Absolute change from a previous mark | Month-over-month change in Sales |
| Percent Difference From | Percentage change from a previous mark | Year-over-year growth rate |
| Percent of Total | Each mark as a share of all marks | Category contribution to total Sales |
| Rank | Position of each mark ordered by value | Sales ranking of Sub-Categories |
| Percentile | Percentile position of each mark | Customer spend percentile |
| Moving Average | Average of the current mark and N preceding marks | Smoothing noisy monthly Sales trend lines |
| YTD Total | Running total reset at each year boundary | Year-to-date cumulative revenue by month |
Compute Using — Controlling the Direction
Every table calculation has a Compute Using setting that controls which Dimension the calculation runs across. Right-click the pill with the delta symbol → Edit Table Calculation → set Compute Using. Getting this setting wrong is the most common table calculation mistake — the calculation runs in the wrong direction and produces numbers that look correct but are meaningless.
Running Total — Step by Step
Running Total vs Monthly Sales — Labelled Mockup
Percent of Total — Step by Step
Writing Table Calculations as Formulas
Quick Table Calculations cover the most common cases. For custom logic, Tableau's table calculation functions can be written directly in the calculation editor. The most useful ones are RUNNING_SUM(), WINDOW_AVG(), RANK(), and INDEX().
RUNNING_SUM — cumulative total of Sales across the view
RUNNING_SUM(SUM([Sales]))
Feb: $43,000 → Running total: $81,000
Mar: $33,000 → Running total: $114,000
Each mark adds its SUM(Sales) to all previous marks. The formula version gives identical results to Quick Table Calculation → Running Total.
WINDOW_AVG — average across a sliding window of marks
WINDOW_AVG(SUM([Sales]), -2, 0)
At March: average of January, February, March Sales = (38K + 43K + 33K) / 3 = $38,000
At April: average of February, March, April = (43K + 33K + 48K) / 3 = $41,333
A 3-month moving average smooths short-term volatility to reveal the underlying trend.
RANK — ranking marks by their aggregated value
RANK(SUM([Sales]), 'desc')
Furniture: $742K → Rank 2
Office Supplies: $719K → Rank 3
'desc' ranks highest value as 1. Use 'asc' to rank lowest value as 1. Ties receive the same rank — RANK_UNIQUE() breaks ties sequentially. RANK_DENSE() does not skip rank numbers after a tie.
The Compute Using setting is the part of table calculations that trips up every analyst at least once. The golden rule is: the Compute Using Dimension is the one the calculation travels across — and every other Dimension in the view is the one it restarts for. A running total with Compute Using set to Order Date (month) will accumulate across months — and if Region is also in the view, it will produce a separate running total per Region automatically, restarting at January for each Region. This is almost always the correct behaviour. If your running total is producing strange jumps or resets, the Compute Using direction is almost certainly set to the wrong Dimension. Right-click the delta pill → Edit Table Calculation → switch to Specific Dimensions and manually check only the Dimension you want the calculation to traverse. The delta symbol on a pill is your first diagnostic — if you see a pill without a delta that you expected to behave like a table calculation, the Quick Table Calculation was not applied. If you see a delta and the numbers look wrong, the Compute Using direction needs adjustment.
Practice Questions
1. A line chart shows monthly SUM(Sales). How do you convert it to a running total using the fastest method available?
2. Write the table calculation formula that computes a 3-month moving average of Sales — averaging the current month and the two preceding months.
3. A running total is producing unexpected resets mid-chart. Where do you go to fix the direction the calculation is running across?
Quiz
1. After applying a Quick Table Calculation, what visual indicator on the pill confirms a table calculation is active on that Measure?
2. A Percent of Total table calculation shows each Sub-Category as a share of the whole. When Region is removed from the view, the percentages change. Why does removing a Dimension affect the table calculation result?
3. A view shows Sub-Categories with their SUM(Sales). Write the table calculation formula that ranks each Sub-Category from highest to lowest Sales, with rank 1 assigned to the highest value.
Next up — Lesson 37: Conditional calculations — using IF, IIF, CASE, and logical operators to build segmentation, flags, and business rules directly inside calculated fields.