EXP(number) returns e (2.71828) raised to the number: EXP(2) is 7.389. DuckDB, Snowflake and BigQuery all call it exp(). It is the inverse of LN, and Tableau's product idiom EXP(SUM(LN([x]))) relies on LN returning null for zero and negatives, so those rows drop out. SQL's product() keeps them.
Updated · Checked on the xmetric engine
What is the syntax?
EXP(number)
number
the exponent.
Returns a positive number: e to the power of the input. Null if the input is null.
What does it return, and what is the SQL?
Each example runs on the same 8 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.
What is e raised to each value?
Tableau
EXP([Value])
SQL (DuckDB)
SELECTexp(Value) AS result
FROM input
ORDERBY id
EXP(0) is 1 and EXP(2.5) is 12.18; EXP(16) is 8.9 million.
Value
Result
2.5
12.18
−2.5
0.08
0.13
1.13
−0.4
0.67
3.75
42.52
null
0
1
16
8,886,111
✓ The Tableau formula and the SQL return the same 8 rows.
What is the product of the positive values per region?
Tableau
EXP(SUM(LN([Value])))
SQL (DuckDB)
SELECT Region,
exp(sum(CASEWHEN Value >0THENln(Value) END)) AS result
FROM input
GROUPBY Region
ORDERBY Region
East multiplies 2.5 by 0.125 (0.3125): LN skips the -2.5, so the SQL must skip it too.
Region
Result
East
0.31
North
16
West
3.75
✓ The Tableau formula and the SQL return the same 3 rows.
Where does a straight translation go wrong?
Common mistake
Why does product() give a different total than EXP(SUM(LN()))?
The Tableau idiom silently drops rows where LN is null (zero and negatives). DuckDB's product() multiplies them all: East becomes -0.78 instead of 0.3125, and North 0 instead of 16.
Tableau
EXP(SUM(LN([Value])))
Tempting SQL
SELECT Region, product(Value) AS result
FROM input
GROUPBY Region
ORDERBY Region
SQL that matches
SELECT Region,
exp(sum(CASEWHEN Value >0THENln(Value) END)) AS result
FROM input
GROUPBY Region
ORDERBY Region
Region
Tableau
Tempting SQL
SQL that matches
East
0.31
−0.78
0.31
North
16
0
16
West
3.75
−1.5
3.75
✓ 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.