Function table / Level of detail / First invoice date

First invoice date, from Tableau to SQL

Returns the earliest invoice date per customer. Below, 8 sample rows go through the calculation and through the SQL, and both return the same numbers.

Calculated field

{ FIXED [Customer] : MIN([Date]) }

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", MIN("Date") AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"

Runs the example above.

Result

Customerresult
Aster2026-01-05
Birch2026-01-12
Clover2026-02-14
Dahlia2026-01-08
Fern2026-01-20

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

Where a naive translation goes wrong

  • MAX returns the most recent invoice; MIN returns the first invoice for customers with several dates.

    Naive SQL

    SELECT "Customer", MAX("Date") AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"
    Customerresult
    Aster2026-02-05
    Birch2026-01-12
    Clover2026-02-14
    Dahlia2026-02-08
    Fern2026-02-20

    Matches the calculation

    SELECT "Customer", MIN("Date") AS result FROM input  GROUP BY "Customer" ORDER BY "Customer"
    Customerresult
    Aster2026-01-05
    Birch2026-01-12
    Clover2026-02-14
    Dahlia2026-01-08
    Fern2026-01-20

Signature

{ FIXED [Customer] : MIN([Date]) }