LOWER(string) returns the string in lower case, accented letters included: Café Nord becomes café nord. DuckDB's lower() is the same. Keep it when you translate a count or a grouping: DuckDB's DISTINCT and GROUP BY are case sensitive.
Updated · Checked on the xmetric engine
What is the syntax?
LOWER(string)
string
the text.
Returns the string in lower case. 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 does each name look like in lower case?
Tableau
LOWER([Name])
SQL (DuckDB)
SELECTlower(Name) AS result
FROM input
ORDERBY id
East and east both become east.
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.
How many different names are there, ignoring case?
Tableau
COUNTD(LOWER([Name]))
SQL (DuckDB)
SELECTcount(DISTINCTlower(Name)) AS result
FROM input
East and east count once: 5 names.
Result
5
✓ The Tableau formula and the SQL return the same 1 rows.
Where does a straight translation go wrong?
Common mistake
Why does count(DISTINCT Name) count one more?
DuckDB compares strings case sensitively, so East and east are two values. Lower them inside the count.
Tableau
COUNTD(LOWER([Name]))
Tempting SQL
SELECTcount(DISTINCT Name) AS result
FROM input
SQL that matches
SELECTcount(DISTINCTlower(Name)) AS result
FROM input
Tableau
Tempting SQL
SQL that matches
5
6
5
✓ 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.