[p] OR [q] is true when either side is true. With a null side it is true if the other side is true, and null otherwise, exactly like SQL. The usual slip is in the IIF around it: a null test gives null in Tableau and ELSE in a CASE.
Updated · Checked on the xmetric engine
What is the syntax?
a OR b
a, b
booleans, or comparisons that return true, false or null.
Returns true, false or null (three-valued logic).
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 rows have p or q true?
Tableau
[p]OR[q]
SQL (DuckDB)
SELECT p OR q AS result
FROM input
ORDERBY id
Row 5 (null, true) is true; row 8 (false, null) is null.
p
q
Result
true
true
true
true
false
true
false
true
true
false
false
false
true
true
null
true
true
false
null
✓ The Tableau formula and the SQL return the same 8 rows.
Where does a straight translation go wrong?
Common mistake
Why does the CASE label row 8 "no"?
False OR null is null, and IIF returns null for a null test. CASE sends it to ELSE. Add a WHEN NOT (...) branch.
Tableau
IIF([p]OR[q], 'yes', 'no')
Tempting SQL
SELECTCASEWHEN p OR q THEN'yes'ELSE'no'ENDAS result
FROM input
ORDERBY id
SQL that matches
SELECTCASEWHEN p OR q THEN'yes'WHENNOT (p OR q) THEN'no'ENDAS result
FROM input
ORDERBY id
p
q
Tableau
Tempting SQL
SQL that matches
true
true
yes
yes
yes
true
false
yes
yes
yes
false
true
yes
yes
yes
false
false
no
no
no
true
yes
yes
yes
null
no
null
true
yes
yes
yes
false
null
no
null
✓ 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.