SUM([Revenue]) / SUM({ FIXED : SUM([Revenue]) }) divides each region's revenue by the grand total, so the regions add up to 100%. In SQL: sum(Revenue) / sum(sum(Revenue)) OVER () over rows grouped by Region. Wrap the FIXED total in an aggregate such as SUM or MIN; it repeats on every mark, so either returns the grand total.
Updated · Checked on the xmetric engine
What is the syntax?
SUM([Revenue]) /SUM({ FIXED : SUM([Revenue]) })
numerator
SUM([Revenue]) per mark.
denominator
the FIXED grand total, wrapped in SUM, MIN or MAX.
Returns a fraction per mark: the region's part of the grand total.
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 share of all revenue does each region make?
Tableau
SUM([Revenue]) /SUM({ FIXED : SUM([Revenue]) })
SQL (DuckDB)
SELECT Region,
sum(Revenue) /sum(sum(Revenue)) OVER () AS result
FROM input
GROUPBY Region
ORDERBY Region
North makes 650 of 1,650: 39.4%. South 33.3%, West 27.3%.
Region
Result
North
0.39
South
0.33
West
0.27
✓ The Tableau formula and the SQL return the same 3 rows.
Does MIN around the FIXED total give the same share?
Tableau
SUM([Revenue]) /MIN({ FIXED : SUM([Revenue]) })
SQL (DuckDB)
SELECT Region,
sum(Revenue) /sum(sum(Revenue)) OVER () AS result
FROM input
GROUPBY Region
ORDERBY Region
Yes. The total is the same on every row, so SUM, MIN and MAX of it agree per mark.
Region
Result
North
0.39
South
0.33
West
0.27
✓ The Tableau formula and the SQL return the same 3 rows.
Where does a straight translation go wrong?
Common mistake
Why is the share tiny when the total comes from a row-level window?
Writing the FIXED as sum(Revenue) OVER () on each line and then summing it per region counts 1,650 once per line: North divides by 8,250 and gets 7.9%.
Tableau
SUM([Revenue]) /SUM({ FIXED : SUM([Revenue]) })
Tempting SQL
SELECT Region, sum(Revenue) /sum(t) AS result
FROM (
SELECT Region, Revenue, sum(Revenue) OVER () AS t
FROM input
)
GROUPBY Region
ORDERBY Region
SQL that matches
SELECT Region,
sum(Revenue) /sum(sum(Revenue)) OVER () AS result
FROM input
GROUPBY Region
ORDERBY Region
Region
Tableau
Tempting SQL
SQL that matches
North
0.39
0.08
0.39
South
0.33
0.07
0.33
West
0.27
0.14
0.27
✓ 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,
SUM(Revenue) /SUM(SUM(Revenue)) OVER () AS result
FROM input
GROUPBY Region
ORDERBY Region
What do people ask about Region share of fixed 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.
Why not a Percent of Total quick table calculation?
It gives the same numbers until you filter: a table calculation divides by what is left in the view, the FIXED total by the whole data source.
Will the shares still add up to 100% after a filter?
No, and that is often the point: with an ordinary filter on Region, the remaining regions still show their share of all revenue.