When to Use the Attribute (ATTR) Function

Published: 27 May 2014
Last Modified Date: 13 Apr 2019


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


Tableau Desktop


ATTR() Indicates Multiple Values

The ATTR() aggregation indicates there are multiple values, but only one was expected.

For example, when blending two or more data sources, fields from the secondary data source are automatically wrapped in ATTR() because fields from a secondary data source must be aggregated. If there are multiple values for a secondary dimension, then ATTR(Secondary Dimension) will show an asterisk in the view, as explained further in Troubleshoot Data Blending: Asterisks show in the sheet.

If another aggregation was used in place of ATTR() then Tableau Desktop would show misleading information. Such as MIN(Secondary Dimension) would show the first dimension value, and there would be no way to tell that there are actually multiple values in the secondary data source. The asterisk is an indication that the relationship or the view needs to be adjusted.

How it Works

ATTR() compares all of the values from each record in the underlying data that are grouped into one partition in the view (e.g. a bar, a circle, a cell, etc... ) and if the values are all the same then ATTR() will return that value. Otherwise ATTR() will return an asterisk.

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 "*" 

(Update the dimension fields [dimension] with your own dimensions.)

Use Cases for ATTR()

  • Per the above example, ATTR() can indicate that there are multiple values from the secondary data source
  • Dimensions added to Tooltip on the Marks card are automatically wrapped in ATTR() because dimensions on Tooltip must be aggregated. If another aggregation like MIN() is used, then the tooltip will show a single value which may mislead the viewer to think there is only a single value. Therefore ATTR() will display an asterisk as an indication that the view or the values added to the tooltip need to be adjusted. See Asterisks Display in Tooltips
  • Like other aggregations, ATTR() can be used to change a non-aggregate value to an aggregate value to resolve aggregation errors in the calculation. See Aggregate Error Messages In a Calculation Editor

    Please note, when a calculation that returns numeric data contains ATTR(), if there are multiple values in the ATTR(), the calculation will return NULL rather than an asterisk.
  • ATTR() can be used as a precaution to guard against data changing


Did this article resolve the issue?