Tableau – User Level Filter

To add user level filter:

CREATE TABLE user_lookup_tbl (
 tableau_user_name VARCHAR(50),
 actual_username VARCHAR(50)
);
SELECT * FROM user_lookup_tbl;

tableau_user_name | actual_username
user1                             a1
user1                             a2
user2                             b1
user3                             c1
user3                             c2
user3                             c3

6 rows selected

CREATE TABLE actual_data_tbl (
username VARCHAR(50),
val int
);

username | val
a1                 10
a1                 20
a1                 50
a2                60
b1                 15
b1                00
b2                65
c1                 22
c2                 11
c2                 09
c3                 99
c3                  89

12 rows selected

SELECT 
               * 
FROM 
             user_lookup_tbl
 JOIN
              actual_data_tbl
ON actual_username = username;

tableau_user_name | actual_username | username | val
user1                             a1                              a1                10
user1                             a1                              a1                20
user1                             a1                              a1                50
user1                             a2                              a2               60
user2                             b1                              b1                15
user2                             b1                              b1                00
user3                             c1                               c1                22
user3                             c2                              c2                11
user3                             c2                              c2                09
user3                             c3                              c3                 99
user3                             c3                              c3                 89

11 rows selected

In tableau Environment
Step 1. Import the both the data sources by doing an inner join on username
Step 2. Drag and drop all the dimensions and measures needed for your analysis/vizualization
Step 3. Create a calculated field giving boolean result of True/False
Calculation:
tableau_user_name = USERNAME()
Step 4. Drag the above created calculated field to Filters pane
Step 5. Save and publish the workbook
Step 6. Now when you login as a specific user into the tableau server, only details or visual facts related to that user will be projected on the canvas

Leave a comment