Tableau function String

Tableau LOWER to SQL

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)

SELECT lower(Name) AS result
FROM input
ORDER BY id

East and east both become east.

NameResult
Ann Leeann lee
bob raybob ray
Café Nordcafé nord
easteast
Easteast
mary-jo o'neilmary-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)

SELECT count(DISTINCT lower(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

SELECT count(DISTINCT Name) AS result
FROM input

SQL that matches

SELECT count(DISTINCT lower(Name)) AS result
FROM input
TableauTempting SQLSQL that matches
565

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

SELECT LOWER(Name) AS result
FROM input
ORDER BY id

Snowflake documentation

BigQuery

SELECT LOWER(Name) AS result
FROM input
ORDER BY id

BigQuery documentation

What does your own LOWER formula return?

Edit the formula and run it on the 7 sample rows. Fields: [id], [Name], [Code], [Email], [Num].

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions go with it?

What do people ask about LOWER?

Does LOWER change digits or punctuation?

No. A-12-x becomes a-12-x.

How do I compare two fields ignoring case?

Lower both: LOWER([Name]) = LOWER([Other]). In SQL, lower(a) = lower(b).

Where is this documented?