Last Modified Date: 30 Nov 2023
Environment
Tableau DesktopAnswer
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 "*"
END
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
Limitations
- Calculated fields containing ATTR() cannot be used to manually set a dynamic sort
- A calculation containing ATTR() may return NULL in the grand total even if it's returning the expected values elsewhere in the view. See Grand Totals Are Blank For Calculated Field That Include ATTR()
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials
Trending Articles
Results 1-3 of 49