Tableau Table Calculations
Table calculations compute values based on what is already in your chart — not from the original database. They run after the data arrives in your view and perform comparisons like running totals, percent of total, and rank. Regular calculated fields compute row by row from the raw data. Table calculations compute cell by cell from the visible chart data.
The Key Difference: Regular vs Table Calculation
Analogy: Exam Results
Raw Data (from database): Student | Score Alice | 85 Bob | 72 Carol | 90 David | 68 Regular Calculated Field — works from the database: "Pass/Fail" = IF [Score] >= 70 THEN "Pass" ELSE "Fail" END → Applied to each raw row individually Table Calculation — works from the chart's visible totals: "Rank" = RANK(SUM([Score])) → Applied after Tableau sums scores and shows them in the chart → Carol = Rank 1, Alice = Rank 2, Bob = Rank 3, David = Rank 4
Adding a Quick Table Calculation
The fastest way to use table calculations is through the right-click menu. Right-click any Measure pill on a shelf or in the view. Select "Quick Table Calculation." A submenu shows the available types. Click one and the chart updates instantly.
Available Quick Table Calculations
| Type | What It Calculates | Use Case |
|---|---|---|
| Running Total | Cumulative sum from first to last | Cumulative sales over time |
| Difference | Value minus the previous value | Month-over-month sales change |
| Percent Difference | Change as a percentage | % growth each month |
| Percent of Total | Each value as % of the grand total | Category's share of total revenue |
| Rank | Position from highest to lowest | Top performing products |
| Percentile | Position in a distribution | Customer spending percentile |
| Moving Average | Average of the last N values | Smoothing a noisy sales trend |
Running Total Example
Diagram: Monthly Sales vs Cumulative Sales
Month | Monthly Sales | Running Total Jan | $500 | $500 Feb | $700 | $1,200 Mar | $400 | $1,600 Apr | $900 | $2,500 May | $600 | $3,100 Monthly Sales → shows each month's result Running Total → shows total accumulated so far Line chart of Running Total = always going up Useful for tracking: "Have we hit $3,000 yet?"
Computing Along: Table Across vs Down
Table calculations have a direction — they can compute across rows (left to right) or down columns (top to bottom). Right-click the measure pill and select "Edit Table Calculation" to change this. The direction determines which values the calculation compares.
Diagram: Compute Direction
Table — Region in Rows, Quarter in Columns
Q1 Q2 Q3 Q4
East | 100 | 110 | 90 | 120 |
West | 80 | 95 | 100 | 85 |
South | 70 | 75 | 80 | 65 |
Compute Along COLUMNS (Table Across):
Percent Diff Q2 vs Q1 for East = (110-100)/100 = 10%
→ "How did this quarter compare to last quarter?"
Compute Along ROWS (Table Down):
Percent Diff West vs East for Q1 = (80-100)/100 = -20%
→ "How does this region compare to the one above?"
Percent of Total
Apply Percent of Total to show each value as a share of the grand total. In a bar chart of sales by product, each bar converts from a dollar amount to a percentage. All bars now add up to 100%. This is cleaner than a pie chart for many categories.
Example: Before and After
Before (SUM): After (% of Total): Furniture $1,200 Furniture 30% Technology $1,800 Technology 45% Office Sup. $1,000 Office Sup. 25% Total $4,000 Total 100%
Rank Calculation
Apply Rank to order items from highest to lowest automatically. Dragging "Rank" from Analytics or using Quick Table Calculation → Rank numbers each item. Sort the chart by Rank to show a top-N style leaderboard. Combine with a filter to show only the top 10.
Writing Table Calculations in the Formula Editor
You can write table calculations directly using functions like RUNNING_SUM(), RANK(), INDEX(), SIZE(), FIRST(), LAST(), and LOOKUP().
Common Table Calculation Functions
RUNNING_SUM(SUM([Sales])) → Cumulative sum from the first row to the current row RANK(SUM([Sales])) → Rank of the current row among all rows INDEX() → Sequential position of the current row (1, 2, 3, ...) SIZE() → Total number of rows in the partition LOOKUP(SUM([Sales]), -1) → Returns the Sales value of the previous row LOOKUP(SUM([Sales]), FIRST()-INDEX()) → Returns the Sales value of the very first row
Partitioning and Addressing
Every table calculation runs within a defined group called a partition. It computes separately within each partition. Addressing defines which direction (across or down) the calculation runs within each partition. For example, compute Running Total separately for each Region — Region is the partition — running month by month — Month is the addressing direction.
Summary
Table calculations compute from the chart's visible data, not the raw database. Running Total accumulates values over time. Percent Difference shows growth. Percent of Total converts amounts to shares. Rank orders items by value. All these run via Quick Table Calculation from a right-click. For advanced control, write formulas using functions like RUNNING_SUM(), RANK(), and LOOKUP() in the calculated field editor. Partition and address settings define which group the calculation runs within and in which direction.
