KNOWLEDGE BASE

When to Use the Attribute (ATTR) Function


Published: 27 May 2014
Last Modified Date: 24 May 2017

Question

How the Attribute (ATTR) function works and is different from other aggregations such as MIN or SUM.

Environment

Tableau Desktop

Answer

The ATTR function filters the View, not the underlying date, and can be an important tool in certain situations especially for working with views based on data blending. ATTR works at the row level and its purpose is to identify if the row is unique. If the row is unique it returns the value, else it returns "*".

In it simplest form, the formula reads like this:
 
IF MIN ([dimension]) = MAX ([dimension]) THEN MIN ([dimension]) ELSE "*"  END

The ATTR function evaluates all the members within the field and returns a value if 1) there is only a single value (MIN = MAX) or 2) all members are identical (MIN = MAX) else it returns "*". Which can be interpreted as "there is more than one value". 

You can build out the basic ATTR function by adding conditions for when the ATTR function should be triggered, for example:
 
IF ISNULL ([dimension]) THEN NULL
ELSEIF MIN ([dimension]) = MAX ([dimension]) THEN MIN ([dimension])
ELSE "*" 
END

Limitations

  • The ATTR function will not work in the same manner as other aggregations such as MIN, MAX, or SUM.
  • ATTR cannot be used as a sorting dimension in a crosstab.
Did this article resolve the issue?