In Tableau, the "ATTR" aggregate function is used to return the single unique value within a specified field or expression when there is only one distinct value present. It stands for "Attribute" and is primarily used when you want to retrieve the unique value of an attribute for a group of records.
The syntax of the "ATTR" function in Tableau is as follows:
ATTR(expression)
Here's an example to illustrate how the "ATTR" function works in Tableau:
Suppose you have a dataset of customers and their corresponding regions. You want to determine the region of a customer group when all customers within that group belong to the same region.
ATTR([Region])
In this example, the "ATTR" function is used to evaluate the expression [Region]
. If all the customers within a specific group belong to the same region, the "ATTR" function will return that region. However, if there are multiple regions within a group, or if the group contains null or different values, the "ATTR" function will return an asterisk (*) to indicate that there is no single unique attribute.
For instance, if you have a group of customers belonging to the region "North," the "ATTR" function will return "North" as the unique attribute of that group. But if the group contains customers from both "North" and "South," the function will return an asterisk (*) to indicate the lack of a single unique attribute.
The "ATTR" function is particularly useful when dealing with aggregated data or when you need to identify the unique attribute of a group. It helps in situations where you want to confirm that all values within a group are the same or when you need to retrieve a single value to represent the attribute of a group.
No comments:
Post a Comment
If you have any doubts. Please let me know