KNOWLEDGE BASE

Filter Table By Username Before Join


Published: 17 Aug 2018
Last Modified Date: 28 Aug 2018

Question

How to filter a table by username before joining it to another table.

Environment

  • Tableau Desktop

Answer

Use Initial SQL to query the database using the Tableau Server username. Follow the steps below:
  1. Connect to a data source that supports Initial SQL
  2. Enter the connection details.
  3. Open the Initial SQL options.
  4. Enter the commands that will pass the Tableau parameters such as [TableauServerUser] to the database.
  5. Click OK and connect to the database.
  6. Connect to the new table created by the commands set in the Initial SQL.
  7. Create a new connection and join the new tables to the table created by the Initial SQL

Additional Information

This is just another method for implementing row level security.

The table created by the Initial SQL should only contain data for the username passed with the Tableau parameters. Joining to this table will then only create a data source that has data relevant to the user logged in without needing to apply any type of user or group filter. The filtering will be performed by setting the conditions in the SQL when creating the connection.

User must have knowledge of how the SQL required for their respective database. The tables/data must also be prepped to a certain extent for this work, such as containing a Username column that matches the Tableau Sever name or some logic in database that will know how to process and return the expected tables.

 
Did this article resolve the issue?