Home » Tableau » ISUSERNAME Function in Tableau

ISUSERNAME Function in Tableau

What is ISUSERNAME function in Tableau

The ISUSERNAME() function in Tableau is also called logical function that returns a Boolean value of True or False based on whether the currently logged-in user matches a specified username or pattern. This function check one users name with boolean value, However the USERNAME function can check and also display username.

The syntax

ISUSERNAME(String) 

ISUSERNAME(“username_pattern”). Here, the “username_pattern” parameter can be either a specific username or a pattern that matches multiple usernames.

For example, “ISUSERNAME(‘johndoe’)” would check if the current user’s username is “johndoe”,

while “ISUSERNAME(‘domain_name*’)” would check if the current user’s username starts with “domain_name”.

Key Features of Tableau ISUSERNAME function

  • Usage: You can use the ISUSERNAME() function in a variety of scenarios, such as filtering data, controlling access to dashboards and worksheets, and customizing calculations or visualizations based on user-specific settings.
  • Flexibility: The ISUSERNAME() function provides a lot of flexibility in terms of matching usernames or patterns. You can use standard wildcard characters like “*” and “?” to match patterns, or you can use regular expressions for more complex matching scenarios.
  • Security: The ISUSERNAME() function can be used as a security measure to restrict access to sensitive data or dashboards. For example, you can use the function in combination with user filters to limit access to certain data or visualizations based on the logged-in user’s username.
  • Customization: By combining the ISUSERNAME() function with other Tableau functions or calculations, you can create highly customized visualizations or dashboards that respond dynamically to changes in the current user’s context. For example, you can use the function to highlight certain data points or change the colour scheme of a chart based on the current user’s preferences or permissions.

Lets take 3 different examples of using the ISUSERNAME() function in Tableau:

Example#1: Filter data based on the current user:

ISUSERNAME function in tableau can be use to Filter the data based on the current user’s username, as shown below formula

ISUSERNAME('johndoe')

This formula will return True if the current user’s username is “johndoe”, and False otherwise. You can use this formula as a filter condition to limit the data displayed in a worksheet or dashboard to data that is relevant to a specific user.

You need to put formula in filter option, then follow below steps

  • Right click on filter and click on Edit filter
  • You will see the Filter edit window then click on Condition tab and enter the formula as shown below image
Put formula ISUSERNAME in filter window in tableau

Example#2: Customize a calculation based on the current username

When you create calculation field in Tableau, you can use ISUSERNAME function to Customize a calculation based on the current user’s username

IF ISUSERNAME('johndoe') THEN [Sales]*1.1 ELSE [Sales] END

This formula will apply a 10% mark-up to the Sales measure for the user “johndoe”, and leave it unchanged for all other users. You can use this formula to create user-specific calculations that adjust the data displayed in a visualization or dashboard based on the current user’s preferences.

another example for dimension view for chart:

IF ISUSERNAME('Depaak') THEN [Region] ELSE [Country] END

If user is “Deepak” then show region view else Country view

Example#3: Control access to a dashboard based on the current user’s username:

You can also Control access to a dashboard based on the current user’s username. below is the formula use for that.

IF ISUSERNAME('johndoe') THEN TRUE ELSE FALSE END

This formula will return True if the current user’s username is “johndoe”, and False otherwise.

You can use this formula as a filter condition or visibility setting to control whether a particular dashboard or worksheet is visible to certain users.