Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone please explain the ATTR Function in Tableau

Tags:

tableau-api

I know that the ATTR function is used for aggregation, but can someone explain it in simple terms?

like image 601
Aman Sheriff Avatar asked Dec 22 '15 12:12

Aman Sheriff


People also ask

Is ATTR an aggregate function?

This is because ATTR is an aggregate function. Any field that is or can be aggregated will show up under Measures. Drag Order ID to the Rows shelf.

What does ATTR return?

The attr() method sets or returns attributes and values of the selected elements. When this method is used to return the attribute value, it returns the value of the FIRST matched element.

What is attribute dimension and measure in Tableau?

Dimensions affect the level of detail in the view. Measures contain numeric, quantitative values that you can measure. Measures can be aggregated. When you drag a measure into the view, Tableau applies an aggregation to that measure (by default).


2 Answers

In the most simplest of terms, ATTR returns a value if it is unique, otherwise it returns "*". I think you'll find this link helpful with examples.

https://www.interworks.com/blog/tcostello/2014/05/15/attr-tableaus-attribute-function-explained

like image 112
Bernardo Avatar answered Jan 04 '23 05:01

Bernardo


You cannot mix aggregate and non aggregate comparisons in tableau, you have to use ATTR, for e.g. if ATTR(segment) ='Corporate' then sum(sales)

like image 42
arya Avatar answered Jan 04 '23 04:01

arya