{ EXCLUDE [Team] : SUM([Revenue]) } computes the sum at the view's level of detail minus Team. In a Region by Team view that is the region total, repeated on each team row. In SQL it is a window over the grouped rows that partitions by the view dimensions you keep: sum(sum(Revenue)) OVER (PARTITION BY Region).
Updated · Checked on the xmetric engine
What is the syntax?
{ EXCLUDE [Team] : SUM([Revenue]) }
dimensions
the view dimensions to leave out; any not in the view are ignored.
aggregate
an aggregate expression, such as SUM([Revenue]).
Returns a number per mark: the aggregate over the view's dimensions minus the excluded ones.
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 the region total on each team row?
Tableau
{ EXCLUDE [Team] : SUM([Revenue]) }
SQL (DuckDB)
SELECT Region,
Team,
sum(sum(Revenue)) OVER (PARTITIONBY Region) AS result
FROM input
GROUPBY Region, Team
ORDERBY Region, Team
Cedar and Pine both show North's 650: EXCLUDE removes Team, so the sum runs over Region only.
Region
Team
Result
North
Cedar
650
North
Pine
650
South
Ash
550
South
Elm
550
West
Oak
450
✓ The Tableau formula and the SQL return the same 5 rows.
What does it return when Team is not in the view?
Tableau
{ EXCLUDE [Team] : SUM([Revenue]) }
SQL (DuckDB)
SELECT Region, sum(Revenue) AS result
FROM input
GROUPBY Region
ORDERBY Region
Excluding a dimension the view doesn't have changes nothing: it is the plain region total.
Region
Result
North
650
South
550
West
450
✓ The Tableau formula and the SQL return the same 3 rows.
Where does a straight translation go wrong?
Common mistake
Why does GROUP BY Region, Team give team totals?
The grouped query keeps Team in the grain. EXCLUDE takes it out, so every team row shows its region's total: Cedar 650, not 500.
Tableau
{ EXCLUDE [Team] : SUM([Revenue]) }
Tempting SQL
SELECT Region, Team, sum(Revenue) AS result
FROM input
GROUPBY Region, Team
ORDERBY Region, Team
SQL that matches
SELECT Region,
Team,
sum(sum(Revenue)) OVER (PARTITIONBY Region) AS result
FROM input
GROUPBY Region, Team
ORDERBY Region, Team
Region
Team
Tableau
Tempting SQL
SQL that matches
North
Cedar
650
500
650
North
Pine
650
150
650
South
Ash
550
250
550
South
Elm
550
300
550
West
Oak
450
450
450
✓ 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 (PARTITIONBY Region) AS result
FROM input
GROUPBY Region, Team
ORDERBY Region, Team
What do people ask about Region total excluding team?
Do filters change it?
Yes. INCLUDE and EXCLUDE are computed after dimension filters, so filtering out a team removes its revenue from the region total too. That is the main practical difference from a FIXED region total.
Can EXCLUDE be used on a row-level calculation?
No. Tableau's help says EXCLUDE can't be used where there are no view dimensions to omit, such as a row-level expression.
How do I show each team's share of its region?
Divide by it: SUM([Revenue]) / SUM({ EXCLUDE [Team] : SUM([Revenue]) }). See Team share within region.