LEASTPROPAGATENULL(expr1, expr2, ...) returns the smallest argument, but null as soon as any argument is null. DuckDB's least() skips nulls, so it needs a guard: CASE WHEN a IS NULL OR b IS NULL THEN NULL ELSE least(a, b) END. Snowflake's and BigQuery's plain LEAST already propagate nulls.
Updated · Checked on the xmetric engine
What is the syntax?
LEASTPROPAGATENULL(expr1, expr2, ...)
expr1, expr2, ...
two or more numbers or numeric expressions.
Returns the smallest argument, or null if any argument 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.
Which is smaller, unless a value is missing?
Tableau
LEASTPROPAGATENULL([Value], [Other])
SQL (DuckDB)
SELECTCASEWHEN Value ISNULLOR Other ISNULLTHENNULLELSEleast(Value, Other)
ENDAS result
FROM input
ORDERBY id
Rows 3 and 6 each miss one value, so both return null. The other rows match plain LEAST.
Value
Other
Result
2.5
4
2.5
−2.5
−3
−3
0.13
null
−0.4
−1
−1
3.75
8
3.75
2
null
0
0.5
0
16
16
16
✓ The Tableau formula and the SQL return the same 8 rows.
Where does a straight translation go wrong?
Common mistake
Why does least() return a value where Tableau returns null?
DuckDB's least() skips nulls, which is Tableau's plain LEAST. Rows 3 and 6 get 0.125 and 2 in the SQL but null in Tableau.
Tableau
LEASTPROPAGATENULL([Value], [Other])
Tempting SQL
SELECTleast(Value, Other) AS result
FROM input
ORDERBY id
SQL that matches
SELECTCASEWHEN Value ISNULLOR Other ISNULLTHENNULLELSEleast(Value, Other)
ENDAS result
FROM input
ORDERBY id
Value
Other
Tableau
Tempting SQL
SQL that matches
2.5
4
2.5
2.5
2.5
−2.5
−3
−3
−3
−3
0.13
null
0.13
null
−0.4
−1
−1
−1
−1
3.75
8
3.75
3.75
3.75
2
null
2
null
0
0.5
0
0
0
16
16
16
16
16
✓ 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
SELECTLEAST(Value, Other) AS result
FROM input
ORDERBY id