User functions reference information about the user who is viewing your dashboard on Tableau Server or Tableau Online. They are helpful for adding user filters or row level filters to your dashboards, so that different users will be able to see different things.
Outline of the different functions:
USERNAME() and FULLNAME() just return the username and full name of the user. For example, when I am signed in to The Information Lab’s Tableau Server, FULLNAME() returns Isabel Cooper.
ISUSERNAME() and ISFULLNAME() return true if the current user’s username/full name matches the one specified in the function, and false if they do not. For example, ISUSERNAME(‘isabel.cooper’) returns True when I am signed in, but False if a different user is signed in.
The ISMEMBEROF() function assesses whether the current user is a member of a specified user group, and returns True or False. For example, ISMEMBEROF(‘All Users’) returns True when I am logged in. However, ISMEMBEROF(‘DS Leadership’) would return False, as I am not a member.
Note - User groups can be created in Tableau Online or Server to help manage your users; you can set permissions so that dashboards can only be viewed by members of a certain group for example.
Below are examples of what these functions return when I am signed in:
Preview as different users:
Helpfully, you can also preview your work as another user in Desktop. To do this, first make sure you are signed into the relevant Tableau Server (Click ‘Server’ > ‘Sign In’). Once you are signed in, click on the arrow next to your name in the bottom right corner of Tableau Desktop. You can then choose to filter the view as another user.
Example use case:
As mentioned, these functions are useful for changing the view in your dashboard based on the user who is viewing it. Let’s say you want to create a dashboard which shows a list of Data Schoolers, and their mentors. However, you want the Data School Leadership to be able to see all the mentees, but each mentor to only see their own mentees:
- First, create your viz. In this case, we might just want a list of mentees and their assigned mentors in a table form, and perhaps some more information such as which stage of the program the mentees are at.
- Next, create a calculated field:
USERNAME() = [mentor] OR ISMEMBEROF(‘Ds Leadership’)
- Drag the calculated field onto filters and select True
- Test out your view by previewing as different users
For each mentee in your viz, the filter will check whether the current user is a member of DS Leadership, or whether the current user matches the mentor. If either of these is true, the mentee will show up in the viz.