{ FIXED [Customer] : SUM([Revenue]) } adds all of a customer's revenue, wherever it appears in the view. Aster buys from two teams; with Team in the view, both rows still show Aster's lifetime 260. In SQL, compute the per-customer total in a subquery and join it back on Customer.
Updated · Checked on the xmetric engine
What is the syntax?
{ FIXED [Customer] : 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 customer's total revenue across the whole data source.
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 customer's lifetime revenue, team by team?
Tableau
{ FIXED [Customer] : SUM([Revenue]) }
SQL (DuckDB)
WITH c AS (
SELECT Customer, sum(Revenue) AS total
FROM input
GROUPBY Customer
)
SELECTDISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDERBY i.Team, i.Customer
Aster shows 260 under both Cedar (where it spent 200) and Pine (60).
Team
Customer
Result
Ash
Fern
100
Ash
Gale
150
Cedar
Aster
260
Cedar
Birch
300
Elm
Dahlia
300
Oak
Holly
450
Pine
Aster
260
Pine
Clover
90
✓ The Tableau formula and the SQL return the same 8 rows.
What does each invoice line carry?
Tableau
{ FIXED [Customer] : SUM([Revenue]) }
SQL (DuckDB)
SELECT id, sum(Revenue) OVER (PARTITIONBY Customer) AS result
FROM input
ORDERBY id
Every line gets its customer's total, so you can bin customers by lifetime value or compare a line with it.
id
Result
1
260
2
260
3
300
4
90
5
260
6
300
7
300
8
100
9
100
10
150
11
450
12
450
✓ The Tableau formula and the SQL return the same 12 rows.
Where does a straight translation go wrong?
Common mistake
Why does GROUP BY Team, Customer split Aster?
Grouping by the view sums Aster per team: 200 and 60. FIXED ignores Team and shows the lifetime 260 on both rows.
Tableau
{ FIXED [Customer] : SUM([Revenue]) }
Tempting SQL
SELECT Team, Customer, sum(Revenue) AS result
FROM input
GROUPBY Team, Customer
ORDERBY Team, Customer
SQL that matches
WITH c AS (
SELECT Customer, sum(Revenue) AS total
FROM input
GROUPBY Customer
)
SELECTDISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDERBY i.Team, i.Customer
Team
Customer
Tableau
Tempting SQL
SQL that matches
Ash
Fern
100
100
100
Ash
Gale
150
150
150
Cedar
Aster
260
200
260
Cedar
Birch
300
300
300
Elm
Dahlia
300
300
300
Oak
Holly
450
450
450
Pine
Aster
260
60
260
Pine
Clover
90
90
90
✓ 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
WITH c AS (
SELECT Customer, SUM(Revenue) AS total
FROM input
GROUPBY Customer
)
SELECTDISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDERBY i.Team, i.Customer
WITH c AS (
SELECT Customer, SUM(Revenue) AS total
FROM input
GROUPBY Customer
)
SELECTDISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDERBY i.Team, i.Customer
What do people ask about Fixed customer lifetime revenue?
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.
How do I bucket customers by lifetime revenue?
FIXED results can be dimensions. Drag the field to Rows, or create bins from it, then count customers with COUNTD([Customer]).
How is this different from INCLUDE [Customer]?
INCLUDE adds Customer to the view's grain, so in a Team view Aster gets 200 and 60. See Mean customer revenue.