← All Kits · Tableau Kit

Calculated Fields in Tableau: The Four Kinds and How to Tell Them Apart

Michael Nocito · Updated August 2026 · Every number on this page was worked before it was published

The calculation editor looks the same for all of them, which is the problem. Four kinds of calculation, one dialog, and the only way to tell which one you have written is to know what the parts do.

What you do: decide the grain before you type. Per row, per mark, per named grain, or across the finished table.

The short version. The question is always at what grain does this run.

1. Row level

Runs once per row of the underlying data, before any grouping.

[Profit] / [Sales]
IF [Status] = "Cancelled" THEN 0 ELSE [Amount] END
DATEDIFF('day', [Ordered], [Shipped])

Use these for classifying and cleaning: a flag column, a band, a difference between two dates on the same row. They behave like a new column in the source, and Tableau will aggregate them for you when they land on a shelf.

The trap: AVG([Profit]/[Sales]) averages the per-row ratios. On rows of very different sizes that is not the profit margin, it is the average of margins, and it can be several points away from the real answer.

2. Aggregate

Runs once per mark, after Tableau has grouped by whatever is on the view.

SUM([Profit]) / SUM([Sales])
COUNTD([Customer])
MIN([Order Date])

This is where a ratio belongs. SUM([Profit])/SUM([Sales]) is the true margin at every level of aggregation, and it re-computes correctly when you change what is on the view.

The error message is a diagnosis. "Cannot mix aggregate and non-aggregate arguments" means half your formula runs per row and half per mark. Wrap the row-level half in SUM, MIN or ATTR. ATTR is the honest one for text: it returns the value if it is the same for every row in the mark, and an asterisk if it is not, which is information rather than a guess.

3. Level of detail expressions

Computed at a grain you specify, in braces, independent of the view.

KeywordMeansTypical use
FIXEDThis grain, ignoring the viewCustomer total shown on a region chart
INCLUDEThe view grain plus these dimensionsAverage of per-customer totals
EXCLUDEThe view grain minus these dimensionsPercent of a total that ignores one dimension
{FIXED [Customer]: SUM([Sales])}
{INCLUDE [Customer]: SUM([Sales])}
{EXCLUDE [Region]: SUM([Sales])}

The classic use is a cohort or a first-order date: {FIXED [Customer]: MIN([Order Date])} gives every row the customer's first order date, which is the foundation of any retention view.

FIXED runs before dimension filters, which is the single most common surprise in Tableau. If a filtered view shows an unfiltered denominator, put the filter in context. That sequence is set out in the order of operations.

4. Table calculations

Run last, on the table of results the view has already produced.

RUNNING_SUM(SUM([Sales]))
INDEX()
SUM([Sales]) / TOTAL(SUM([Sales]))
LOOKUP(SUM([Sales]), -1)

Because they operate on the result table, they depend on how the table is laid out, which is what Compute Using controls. Change the view and a table calculation can change meaning without you editing it. That property is covered in table calculations.

Choosing between them

You wantKindExample
A flag or band per rowRow levelIF [Days] > 30 THEN "Late" ELSE "On time" END
A ratio at any levelAggregateSUM([Profit])/SUM([Sales])
Each customer's first order dateFIXED{FIXED [Customer]: MIN([Order Date])}
Rank within the viewTable calcRANK(SUM([Sales]))
Difference from last monthTable calcZN(SUM([Sales]) - LOOKUP(SUM([Sales]), -1))
Average order size per customerINCLUDEAVG({INCLUDE [Customer]: SUM([Sales])})

Habits that make calculations maintainable

  1. Name them for what they mean, not for what they do. Margin, not Calc1 and not SUM Profit over SUM Sales.
  2. Put a comment at the top with //. Two lines saying what grain it runs at and why saves the next person an hour.
  3. Build in steps. Three small named calculations beat one long nested one, and each can be dropped on a sheet and checked.
  4. Check every calculation against a number you know, at two different levels of aggregation. Many calculation bugs are correct at one level and wrong at another.
  5. Use ZN around anything that can be null in an arithmetic chain, or one missing month quietly empties a running total.

How to apply this to your own work

  1. Open a workbook you inherited and classify every calculated field into one of the four kinds.
  2. Find any AVG of a row-level ratio and compare it to the SUM over SUM version. Note the gap.
  3. Check every FIXED against the filters that ought to affect it.
  4. Add a two-line comment to your five most-used calculations.
  5. Validate one calculation at the row level and again at the total. Agreement at both is the test.

The one habit to keep

Say the grain out loud before typing: per row, per mark, per customer, or across the table. Every Tableau calculation question is that question wearing different clothes.

Which kind is the calculation you rely on most, and does it respect your filters?

Written from the tool as it ships. The four calculation kinds, the mixed-argument error and the LOD keywords are all standard Tableau Desktop behaviour.
Cannot mix aggregate and non-aggregate arguments is Tableau telling you which kind you wrote.

Tableau for Analysts is 110 pages on how Tableau actually thinks: dimensions against measures, relationships against joins, sets, and level of detail. Enough that you stop dragging fields until it looks right.

Tableau for Analysts, $19 →
Calculations are where Tableau stops being drag and drop.

Table calculations covers the fourth kind in depth, and the order of operations explains when each one runs.

Read Table Calculations →