Common Table
Calculations
Master LOOKUP, WINDOW_SUM, and other essential table calculations to unlock powerful analytics in Tableau.
What Are Table Calculations?
Table calculations are computed locally in the visualization rather than in the data source. They transform values that Tableau has already aggregated, allowing you to compute things like running totals, percent differences, and moving averages without writing SQL or altering your data.
The Computation Pipeline
Why Table Calcs Matter
Core Functions Overview
LOOKUP: Referencing Other Rows
expression: any aggregated measure or table calculation.
offset: an integer indicating how many rows forward (positive) or backward (negative) to look. An offset of 0 returns the current row's value.
WINDOW_SUM: Summing Across a Range
start and end are offsets relative to the current row. Use FIRST() and LAST() to reference the partition boundaries dynamically.
Addressing vs. Partitioning
More Essential Functions
How to Apply Table Calculations
Example 1: Running Total
Given monthly sales data, create a cumulative total that grows as you move across months.
| Month | SUM(Sales) | RUNNING_TOTAL |
|---|---|---|
| Jan | $10,000 | $10,000 |
| Feb | $15,000 | $25,000 |
| Mar | $12,000 | $37,000 |
| Apr | $18,000 | $55,000 |
Example 2: LOOKUP for Period Comparison
Compare each quarter's profit to the previous quarter to find the period-over-period change.
SUM([Profit]) - LOOKUP(SUM([Profit]), -1)
| Quarter | SUM(Profit) | LOOKUP(..., -1) | Difference |
|---|---|---|---|
| Q1 | $8,000 | NULL | NULL |
| Q2 | $12,000 | $8,000 | +$4,000 |
| Q3 | $9,500 | $12,000 | -$2,500 |
| Q4 | $14,000 | $9,500 | +$4,500 |
Example 3: Percent of Total
Use WINDOW_SUM to compute each category's share of the grand total.
| Category | SUM(Sales) | WINDOW_SUM | % of Total |
|---|---|---|---|
| Technology | $120K | $300K | 40.0% |
| Furniture | $90K | $300K | 30.0% |
| Office Supplies | $90K | $300K | 30.0% |
Understanding FIRST() and LAST()
Common Mistakes
Summary Comparison
| Function | Purpose | Key Parameters | Output |
|---|---|---|---|
| LOOKUP | Reference another row | expression, offset | Single value |
| WINDOW_SUM | Sum across a range | expression, start, end | Aggregate of window |
| RUNNING_TOTAL | Cumulative sum | expression | Running aggregate |
| WINDOW_AVG | Average across a range | expression, start, end | Moving average |
| INDEX() | Row position | none | Integer (1, 2, 3...) |
| FIRST() / LAST() | Offset to boundaries | none | Integer offset |
Question 1 of 5
Table calculations in Tableau are computed:
Question 2 of 5
If you are on Row 3 of a 5-row partition, what does LOOKUP(SUM([Sales]), -2) return?
Question 3 of 5
To compute each category's share of the grand total, which formula is correct?
Question 4 of 5
In the context of table calculations, what does "partitioning" control?
Question 5 of 5
Why does LOOKUP(SUM([Profit]), -1) return NULL for the first row in a partition?