Function table / Level of detail / Fixed customer lifetime revenue

Fixed customer lifetime revenue, from Tableau to SQL

Adds invoices at customer grain. Below, 8 sample rows go through the calculation and through the SQL, and both return the same numbers.

Calculated field

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

Sample data

RegionTeamCustomerRevenueSeatsDate
NorthCedarAster12042026-01-05
NorthCedarAster8022026-02-05
NorthCedarBirch30062026-01-12
NorthPineClover9032026-02-14
SouthElmDahlia20052026-01-08
SouthElmDahlia10022026-02-08
SouthAshFern7532026-01-20
SouthAshFern2512026-02-20

The same calculation as SQL

SELECT "Customer", SUM(Revenue) AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"

Runs the example above.

Result

Customerresult
Aster200
Birch300
Clover90
Dahlia300
Fern100

Same rows from the calculation and from the SQL in DuckDB.

Where a naive translation goes wrong

  • Averaging invoice rows does not compute customer lifetime revenue when customers have multiple invoices.

    Naive SQL

    SELECT "Customer", AVG(Revenue) AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"
    Customerresult
    Aster100
    Birch300
    Clover90
    Dahlia150
    Fern50

    Matches the calculation

    SELECT "Customer", SUM(Revenue) AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"
    Customerresult
    Aster200
    Birch300
    Clover90
    Dahlia300
    Fern100

Signature

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