User and Pass-Through Function in Tableau

User and Pass-Through Function in Tableau

3 mins read494 Views Comment
Updated on Jul 11, 2022 09:34 IST

In this article, we will discuss user and pass through function in tableau with the help of an example in most simplified way.

2022_07_feature-images_USER-AND-PASS-THROUGH-FUNCTION.jpg

In this article, we will discuss the User function and Pass-Through Function in a tableau that is very useful while doing calculations apart from Number Function, Date Function, Logical Function, Data Type Conversion Function, and Aggregate Function in the Tableau which we have already covered.

Recommended online courses

Best-suited Tableau courses for you

Learn Tableau with these high-rated online courses

Free
3 hours
Free
21 hours
Free
5 hours
Free
– / –
39.54 K
2 hours
– / –
– / –
Free
19 hours
8.4 K
3 weeks
Free
2 hours
– / –
– / –

User Function

It is used to create a user filter or row-level security filter so that only certain people can see the visualization published to Tableau Server and Tableau Online. 

Let’s understand the use of user function by a very simple example:

Assume that the University of Delhi published the result of the semester exam of the mathematics department but the university wants to allow students to see their only own numbers when they access that visualization.

Here, Tableau offers a unique function ISMEMBEROF() that returns the TRUE, if the student is a member of the department of mathematics and when you filter the view using this calculated field, only a student who is searching for his/her marks can see the data but if the student is not from the department of mathematics it will return NULL.

Must Read: What is Tableau?

Sort Data in Tableau
Sort Data in Tableau
In this article, we will discuss about sorting and different methods how to sort data in tableau briefly with examples.
How to Create Sets in Tableau
How to Create Sets in Tableau
In this article, we will briefly discuss one of the tableau’s most powerful analytic features i.e. sets in tableau and how to create, use and delete them.
How to Create Group in Tableau
How to Create Group in Tableau
In this article, we will briefly discuss about groups in tableau, how to create groups and finally what are the differences between tableau groups and tableau sets. In this article,...read more

User Function Available in Tableau

FULLNAME

  • It will return the full name of the user
  • Syntax: FULLNAME()
  • Example: [Student] = FULLNAME()
    • If student Vikram Singh is signed in, the above formula will return TRUE only if the student field in the view contains Vikram Singh.

ISFULLNAME

  • It will return TRUE if the current user name matches the input name
  • Return False, if the given name doesn’t match the current user name
  • Syntax: ISFULLNAME(string)
  • Example: ISFULLNAME (“Vikram Singh”)
    • It will return TRUE if Vikram Singh is the current user; otherwise, false

ISMEMBEROF

  • It will return TRUE if the current user is a member of a defined group that matches the given string
  • If the person is not signed in, it will return NULL.
  • Syntax: ISMEMBEROF(string)
  • Example: 

IF ISMEMBEROF (“Department of Mathematics”) 

THEN “STUDENT NAME”

ELSE “NOT FOUND”

END

It will return TRUE if the student’s name matches in Department of Mathematics; otherwise, FALSE

USERNAME

  • It will return the username of the current user
    • It is similar to FULLNAME()
  • Syntax: USERNAME( )
  • Example:  [Student] = USERNAME()
    • If student Vikram is signed in, the above function will return TRUE only if the student field in the view contains Vikram.

ISUSERNAME

  • It will return TRUE if the current username matches the input username; otherwise, it will return FALSE.
  • Syntax: ISUSERNAME(string)
  • Example:  ISUSERNAME(“Vikram”)
    • The above formula will return TRUE if Vikram is the current user; otherwise, FALSE
    • “All Users” will always return as TRUE.
How to Create Hierarchies in Tableau
How to Create Hierarchies in Tableau
In this article, we will discuss hierarchies in tableau, how to create and remove hierarchies in tableau with examples.
How to Create a Forecast in Tableau
How to Create a Forecast in Tableau
In this article, we will discuss what is forecasting, how does forecasting works in tableau, data requirement and constraints and finally how to create forecasting in tableau.
Highlight Actions in Tableau
Highlight Actions in Tableau
In this article, we will briefly discuss highlighting actions in tableau and different methods to highlight the data with examples.

Pass-Through Function (RAWSQL)

It sends the SQL expressions directly to the database without being interpreted by Tableau. It is beneficial while using Tableau’s custom function that is not recognized (or doesn’t known by tableau).

Must Check: Tableau Online Course and Certifications

Tableau offers different RAWSQL Functions, so let’s explore them:

RAWSQL Function available in Tableau

Note: In the functions, we will use %n. It is used as a substitution syntax for a database value.

RAWSQL_BOOL

  • It will return a boolean result from the given SQL expression
  • Syntax: RAWSQL_BOOL(“sql_expr”, [arg1], [arg1], ….,[argN])
  • Example: RAWSQL_BOOL(“ %1 > %2”, [Sales], [Profit])
    • The above expression will return True or False depending whether Profit > Sales or Profit < Sales
    • In the above expression %1 denotes Sales while %2 denotes Profit

RAWSQL_DATE/RAWSQL_DATETIME

  • It will return the date (or date time) result from a given SQL expressions
  • Syntax: RAWSQL_DATE/RAWSQL_DATETIME(“sql_expr”, [arg1], …[argN])
  • Example: RAWSQL_DATE(“%1”, [Ship Date], [Order Date])

RAWSQL_INT/RAWSQL_REAL/RAWSQL_STR

  • It will return an integer/numeric/string result from a given SQL expression 
  • Syntax:  RAWSQL_INT/RAWSQL_REAL/RAWSQL_REAL(“sql_expr”, [arg1], …[argN])
  • Example: 
    • RAWSQL_INT(“100 + %1”, [Profit])
    • RAWSQL_REAL(“123.345 + %1”, [Profit])
    • RAWSQL_STR(“ %1”, [Student_Name]

RAWSQL_SPATIAL

  • It will return a spatial function from a given SQL expression
  • Syntax: RAWSQL_SPATIAL(“sql_expr”, [arg1], …[argN])

Example: RAWSQL_SPATIAL(“%1”, [Geometry])

Conclusion

In this article, we have discussed user and pass through function in tableau with the help of an example in most simplified way.

Hope this article, will help you in your data analytics journey.

About the Author