FULLNAME() returns the viewer's display name, not their login: "Local Analyst", where USERNAME() returns TIN\analyst. In SQL, pass the viewer's full name in alongside the user name and compare it with a column of full names. The sample runs as a stand-in viewer: user name TIN\analyst, full name Local Analyst, domain TIN, in no groups. In SQL the viewer is a one-row viewer table; in production your app passes it in.
Updated · Checked on the xmetric engine
What is the syntax?
FULLNAME()
Returns a string: the full display name of the person viewing, such as "Local Analyst". The same value on every row.
What does it return, and what is the SQL?
Each example runs on the same 6 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.
What is the viewer's full name?
Tableau
FULLNAME()
SQL (DuckDB)
WITH viewer AS (
SELECT'TIN\analyst'AS username,
'Local Analyst'AS fullname,
'TIN'AS domain
)
SELECT v.fullname AS result
FROM input i, viewer v
ORDERBY i.id
One value, repeated on every row.
Result
Local Analyst
Local Analyst
Local Analyst
Local Analyst
Local Analyst
Local Analyst
✓ The Tableau formula and the SQL return the same 6 rows.
Which rows name the viewer as owner?
Tableau
FULLNAME() =[OwnerName]
SQL (DuckDB)
WITH viewer AS (
SELECT'TIN\analyst'AS username,
'Local Analyst'AS fullname,
'TIN'AS domain
)
SELECT v.fullname = i.OwnerName AS result
FROM input i, viewer v
ORDERBY i.id
Rows 1 and 4. Row 5 has no owner name, so the test is null.
OwnerName
Result
Local Analyst
true
Mai Tran
false
Bao Le
false
Local Analyst
true
null
Linh Pham
false
✓ The Tableau formula and the SQL return the same 6 rows.
Where does a straight translation go wrong?
Common mistake
Why does the full name match no owner?
FULLNAME is the display name. Compared with the Owner column, which holds user names, it never matches. Compare full names with full names, or better, user names with user names: two people can share a display name.
Tableau
FULLNAME() =[OwnerName]
Tempting SQL
WITH viewer AS (
SELECT'TIN\analyst'AS username,
'Local Analyst'AS fullname,
'TIN'AS domain
)
SELECT v.fullname = i.Owner AS result
FROM input i, viewer v
ORDERBY i.id
SQL that matches
WITH viewer AS (
SELECT'TIN\analyst'AS username,
'Local Analyst'AS fullname,
'TIN'AS domain
)
SELECT v.fullname = i.OwnerName AS result
FROM input i, viewer v
ORDERBY i.id
OwnerName
Tableau
Tempting SQL
SQL that matches
Local Analyst
true
false
true
Mai Tran
false
false
false
Bao Le
false
false
false
Local Analyst
true
false
true
null
null
null
Linh Pham
false
false
false
✓ 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 OwnerName = $ viewer_fullname AS result
FROM input
ORDERBY id
The database only knows the account Tableau connects with. Pass the viewer in: Tableau's Initial SQL can use the [TableauServerUser] parameter, or your app sets a session variable or a query parameter. Then filter with it, as the viewer table does on this page.
What does it return in Tableau Desktop?
When you are signed in to Tableau Server or Cloud, the server's user. Otherwise Desktop uses your local or network identity. Test row-level security as a real viewer on the server, not from Desktop.