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 domain?
SQL (DuckDB)
WITH viewer AS (
SELECT
'TIN\analyst' AS username,
'Local Analyst' AS fullname,
'TIN' AS domain
)
SELECT v.domain AS result
FROM input i, viewer v
ORDER BY i.id
One value, repeated on every row.
✓ The Tableau formula and the SQL return the same 6 rows.
How do I show rows only to viewers in the TIN domain?
Tableau
USERDOMAIN() = 'TIN' AND [Owner] = USERNAME()
SQL (DuckDB)
WITH viewer AS (
SELECT
'TIN\analyst' AS username,
'Local Analyst' AS fullname,
'TIN' AS domain
)
SELECT v.domain = 'TIN' AND i.Owner = v.username AS result
FROM input i, viewer v
ORDER BY i.id
Rows 1 and 4 pass. Row 5 has no owner, so the test is null.
| Owner | Result |
|---|
| TIN\analyst | true |
| mai | false |
| bao | false |
| TIN\analyst | true |
| null |
| linh | false |
✓ The Tableau formula and the SQL return the same 6 rows.