Tableau ATTR Function

The Tableau ATTR function is a unique attribute function that returns the * if there are multiple values in the current context; otherwise, it returns the single. This article shows how to use this ATTR function and shows the signs of multiple entries with examples.

The syntax of the Tableau ATTR function is as shown below.


Tableau ATTR function Examples

We will create a simple Employee table using the CSV file source to demonstrate this ATTR special attribute function. Add Occupation, Education, First Name, and Last Name to the Rows shelf. Next, add the Sales and Yearly Income to Measure Values to create the below table report. For the remaining charts in Tableau, please click here.

If you observe the below table, there are duplicates or multiple entries for Education, First Name, and Last Name.

First, we must create a calculated Field to use or write this built-in Tableau ATTR function because we must write an expression. To do this, right-click the empty space within the Measures shelf to select the Create Calculated Field.. option. Otherwise, use the Analysis Menu and choose the Create Calculated Field.. option.

The expression below will apply the ATTR function to the Education column. For more functions >> Click Here!

Create a calculated field to write Tableau ATTR Function

First, drag and drop the Emp ID column to the Measure Values Shelf. Click the down arrow beside the Field and choose Measure and Count.

Next, let me add that CalEdu calculated Field to the table and remove the First and Last Names. If you look at the output, except for the Admin occupation, the remaining three rows have a * symbol because there are multiple Educational entries for each occupation (current context).

For instance, the Employee with a Graduate Degree and Partial High School education has a Clerical occupation. So, instead of showing all of them, the Tableau ATTR function shows the * symbol.

Tableau ATTR Function returns * asterisk

Please add the actual Education column to the Rows shelf beside the CalEdu to show the actual fields instead of the * marks.

Let me create one more calculated Field to apply the Tableau ATTR function to the first name column.

ATTR([First Name])

When you add this calculated Field, it will show the result below.

Tableau ATTR Function on string column

To see the attribute of the first name in the context of education, add the Education column. To see all the fields, add FirstName beside the CalFirstName field.

Add the original first name column