LTRIM(string) removes the spaces at the start of a string and keeps the ones at the end. DuckDB's ltrim() does the same. trim() is not a shortcut: it strips both sides.
Updated · Checked on the xmetric engine
What is the syntax?
LTRIM(string)
string
the text.
Returns the string without leading spaces. Null if the string is null.
What does it return, and what is the SQL?
Each example runs on the same 7 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.
What is left after removing leading spaces?
Tableau
LTRIM(' '+[Name]+' ')
SQL (DuckDB)
SELECTltrim(' '|| Name ||' ') AS result
FROM input
ORDERBY id
The two trailing spaces stay.
Name
Result
Ann Lee
Ann Lee
bob ray
bob ray
Café Nord
Café Nord
east
east
East
East
mary-jo o'neil
mary-jo o'neil
null
✓ The Tableau formula and the SQL return the same 7 rows.
Where does a straight translation go wrong?
Common mistake
Why does trim() lose the trailing spaces?
trim() strips both ends; LTRIM only the start. The difference matters when you later concatenate or pad.
Tableau
LTRIM(' '+[Name]+' ')
Tempting SQL
SELECTtrim(' '|| Name ||' ') AS result
FROM input
ORDERBY id
SQL that matches
SELECTltrim(' '|| Name ||' ') AS result
FROM input
ORDERBY id
Name
Tableau
Tempting SQL
SQL that matches
Ann Lee
Ann Lee
Ann Lee
Ann Lee
bob ray
bob ray
bob ray
bob ray
Café Nord
Café Nord
Café Nord
Café Nord
east
east
east
east
East
East
East
East
mary-jo o'neil
mary-jo o'neil
mary-jo o'neil
mary-jo o'neil
null
null
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.