Tableau function Level of detail

Tableau FIXED region total to SQL

{ FIXED [Region] : SUM([Revenue]) } adds revenue per region, whatever else the view shows: with Region and Team in the view, every team row carries its region's total. In SQL that is a window over the grouped rows, sum(sum(Revenue)) OVER (PARTITION BY Region), or a join to a per-region subquery.

Updated · Checked on the xmetric engine

What is the syntax?

{ FIXED [Region] : SUM([Revenue]) }
dimensions
the fields the aggregate is grouped by, whatever the view shows.
aggregate
an aggregate expression, such as SUM([Revenue]).

Returns a number per row: the total revenue of that row's region.

What does it return, and what is the SQL?

Each example runs on the same 12 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.

What is each team's region total?

Tableau

{ FIXED [Region] : SUM([Revenue]) }

SQL (DuckDB)

SELECT
  Region,
  Team,
  sum(sum(Revenue)) OVER (PARTITION BY Region) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team

Both North teams show 650 and both South teams 550, though the teams alone make North 650 (Cedar 500, Pine 150), South 550 (Ash 250, Elm 300), West 450.

RegionTeamResult
NorthCedar650
NorthPine650
SouthAsh550
SouthElm550
WestOak450

The Tableau formula and the SQL return the same 5 rows.

What does the FIXED value look like on each invoice line?

Tableau

{ FIXED [Region] : SUM([Revenue]) }

SQL (DuckDB)

SELECT id, sum(Revenue) OVER (PARTITION BY Region) AS result
FROM input
ORDER BY id

A FIXED expression is a row-level value: every line carries its region's total, which is why it can be compared with [Revenue] on the same row.

idResult
1650
2650
3650
4650
5650
6550
7550
8550
9550
10550
11450
12450

The Tableau formula and the SQL return the same 12 rows.

Where does a straight translation go wrong?

Common mistake

Why does GROUP BY Region, Team give team totals?

FIXED ignores the view's dimensions. Grouping by the view sums each team, so Cedar shows 500 instead of North's 650.

Tableau

{ FIXED [Region] : SUM([Revenue]) }

Tempting SQL

SELECT Region, Team, sum(Revenue) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team

SQL that matches

SELECT
  Region,
  Team,
  sum(sum(Revenue)) OVER (PARTITION BY Region) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team
RegionTeamTableauTempting SQLSQL that matches
NorthCedar650500650
NorthPine650150650
SouthAsh550250550
SouthElm550300550
WestOak450450450

The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.

Common mistake

Why does summing a row-level window multiply the total?

Tableau joins the region total to each mark once. Putting sum(Revenue) OVER (PARTITION BY Region) on every line and then summing per team adds it once per line: Cedar has three lines, so 3 x 650.

Tableau

SUM({ FIXED [Region] : SUM([Revenue]) })

Tempting SQL

SELECT Region, Team, sum(t) AS result
FROM (
  SELECT
    Region,
    Team,
    sum(Revenue) OVER (PARTITION BY Region) AS t
  FROM input
)
GROUP BY Region, Team
ORDER BY Region, Team

SQL that matches

SELECT
  Region,
  Team,
  sum(sum(Revenue)) OVER (PARTITION BY Region) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team
RegionTeamTableauTempting SQLSQL that matches
NorthCedar6501,950650
NorthPine6501,300650
SouthAsh5501,650550
SouthElm5501,100550
WestOak450900450

The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.

How do I write it in Snowflake or BigQuery?

The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.

Snowflake

SELECT
  Region,
  Team,
  SUM(SUM(Revenue)) OVER (PARTITION BY Region) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team

Snowflake documentation

BigQuery

SELECT
  Region,
  Team,
  SUM(SUM(Revenue)) OVER (PARTITION BY Region) AS result
FROM input
GROUP BY Region, Team
ORDER BY Region, Team

BigQuery documentation

What does your own Fixed region total formula return?

Edit the formula and run it on the 12 sample rows. Fields: [id], [Region], [Team], [Customer], [Invoice], [Revenue], [Date].

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions go with it?

What do people ask about Fixed region total?

Do filters change it?

Ordinary dimension filters on the Filters shelf do not: FIXED is computed before them. Add a filter to context (or filter the data source) to make it count only the rows that survive. In SQL, a context filter is a WHERE inside the subquery or window; an ordinary filter is a WHERE that does not reach it.

What aggregation does Tableau put around it?

SUM by default. Because the region total is coarser than the view, the value is repeated, and SUM, AVG, MIN and MAX of a repeated value all return it. Tableau's help says the same.

How is this different from EXCLUDE [Team]?

Same numbers here; see Region total excluding team. EXCLUDE responds to the view and to dimension filters, FIXED to neither.

Where is this documented?