RAWSQL_STR("upper(%1)", [Product]) sends upper(Product) to the database and reads the answer as a string. In SQL, write the expression with the column in place of %1. Watch string joins: || returns null when any part is null, concat() skips the null part, and databases disagree on which one their CONCAT does.
SELECT Region ||' / '|| Product AS result
FROM input
ORDERBY id
|| is null as soon as one side is null, so line 5 returns null rather than "West / ".
Region
Product
Result
East
Desk
East / Desk
East
Lamp
East / Lamp
East
Chair
East / Chair
West
Shelf
West / Shelf
West
null
North
Desk
North / Desk
✓ The Tableau formula and the SQL return the same 6 rows.
Where does a straight translation go wrong?
Common mistake
Why does concat() label the line with no product?
The RAWSQL text uses ||, which returns null when a part is null. DuckDB's concat() skips nulls and returns "West / " for line 5. Keep the operator the text used, or wrap the result in a null check.
The first argument after the SQL string. %2 is the second, and so on, whatever order the placeholders appear in the text. To translate a RAWSQL call, replace each %n with the column it points at and keep the rest of the text.
Does Tableau check the SQL inside RAWSQL?
No. Tableau passes the text to the database as it is, so a typo or a function your database lacks fails at query time, in the database. The text is also tied to that database's dialect: point the workbook at a different database and the same text can fail or mean something else.
Is CONCAT null-safe everywhere?
No. DuckDB's concat() skips nulls; Snowflake's CONCAT and BigQuery's CONCAT return null if any argument is null, the same as ||. Check the target database before you swap one for the other.