Tableau function Level of detail

Tableau FIXED customer lifetime revenue to SQL

{ 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
  GROUP BY Customer
)
SELECT DISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDER BY i.Team, i.Customer

Aster shows 260 under both Cedar (where it spent 200) and Pine (60).

TeamCustomerResult
AshFern100
AshGale150
CedarAster260
CedarBirch300
ElmDahlia300
OakHolly450
PineAster260
PineClover90

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 (PARTITION BY Customer) AS result
FROM input
ORDER BY id

Every line gets its customer's total, so you can bin customers by lifetime value or compare a line with it.

idResult
1260
2260
3300
490
5260
6300
7300
8100
9100
10150
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 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
GROUP BY Team, Customer
ORDER BY Team, Customer

SQL that matches

WITH c AS (
  SELECT Customer, sum(Revenue) AS total
  FROM input
  GROUP BY Customer
)
SELECT DISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDER BY i.Team, i.Customer
TeamCustomerTableauTempting SQLSQL that matches
AshFern100100100
AshGale150150150
CedarAster260200260
CedarBirch300300300
ElmDahlia300300300
OakHolly450450450
PineAster26060260
PineClover909090

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
  GROUP BY Customer
)
SELECT DISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDER BY i.Team, i.Customer

Snowflake documentation

BigQuery

WITH c AS (
  SELECT Customer, SUM(Revenue) AS total
  FROM input
  GROUP BY Customer
)
SELECT DISTINCT i.Team, i.Customer, c.total AS result
FROM input i JOIN c USING (Customer)
ORDER BY i.Team, i.Customer

BigQuery documentation

What does your own Fixed customer lifetime revenue 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 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.

Where is this documented?