×

Data

# ATTR() – Tableau’s Attribute Function Explained

//

I have a love / hate relationship with the Attribute function in Tableau. I love it for what it does, I hate it for those times that someone asks me to describe what it does. It took me a long time to wrap my head around what ATTR() does in Tableau.

The first stop in my journey to understand the Attribute function was the Tableau online help. There, I found the following definition under ‘Aggregating Data’:

## In Plain English

I found this to be useful, but I can see how non-developers might get lost in this formula. My next step to crack this code was to reach out to my team. James Wright offered this definition:

“Attribute is a test for heterogeneity across the rows in the result set or homogeneity, depending on your perspective. Does every row have the same value? If so, value. If not, *.”

I LOVE this definition, but as Rob Austin in our UK office pointed out, it could possibly benefit from some simplification. Here’s how Rob defines Attribute.

“It returns a value if it is unique, else it returns *.”

I found this to be a great definition and very close to the one found in the Calculated Field Editor.

## ATTR() in Action

Let’s take a look at some data in Tableau and see if we can make sense of what’s going on based on these four ways of defining Attribute. In the following screenshot, I’ve created a simple crosstab showing the sum of Sales by City and State.

Now, let’s apply the Attribute function to the State dimension.

Replace the State pill in our view with the ATTR State pill (from the Measures shelf).

What was the result of this change?

In the “Before” version of our table, we see all three states associated with Albany, one state each for Albemarle and Albuquerque, and two states for Alexandria. When we apply the attribute function to State we see the value of State returned where there was only one possible value (Albemarle, Albuquerque, Allen) and a star (*) returned where there was more than one possible value.

## An Explanation

The way I look at this, Tableau is aggregating on the State value and showing us the state when it can: when the min(State) = max(State). In other words, there is only one possible value for State associated with a given city. If there is more than one possible value, it returns the *. I read the * as Tableau’s way of saying, “Hey, I see more than one of this thing, so I’ll show you an asterisk as my way of saying ‘more than one.’” One thing worth noting, the sum of Sales was correct in each instance.

That’s not all there is to this story, I’ll dive even deeper into this puzzle in my next post!

### The Latest

• ##### Federated Governance: Part Centralised, Part Devolved
Easily move to Tableau Cloud with our Tableau Cloud Migration checklist.

### KeepWatch by InterWorks

Whether you need support for one platform or many, our technical experts have you covered.

## Tim Costello

Analytics Consultant
3 Reasons Why You Should Want a Data Warehouse I hear a lot of reasons people avoid a data warehouse: It takes too long to build, data warehouse projects are expensive and often end ...
My Speaker Idol Talk from SQL PASS Summit 2014 Tim Costello shares his Speaker Idol talk from SQL PASS Summit 2014. Speaker Idol is a speaking contest among 12 of the sharpest SQL ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×