14 Replies Latest reply on Sep 27, 2013 2:13 PM by Lee Feinberg

    Attribute?

    Brent Malak

      What is the purpose of, or what happens to an element, on a column or row shelf that is changed to an "attribute"?  I understand the difference between dimension or measure, but when I right-click on a dimension and change it to an "attribute," what is happening?

        • 1. Re: Attribute?
          Dimitri.B

          When converted to attribute, the dimension becomes just a label. In other words, it is not used to partition the data. There are many complex situations when this is needed, but for the lack of real example I had to invent one.

           

          Let's say we arranged a view the way we needed and now we want to add a table calculation, but the way our view is arranged does not work for this kind of calculation. We can either re-arrange the view or we can convert some dimension to attributes, which will leave the view as is and will allow the table calculation to work. See attached image for details.

           

          I hope this helps, at the same time it would be great it someone can come up with a real example.

          11 of 11 people found this helpful
          • 2. Re: Attribute?
            Brent Malak

            Thank you for the response and explanation.  That makes sense...from my experience, it works much like a "domain aggregate" function.  I just wonder why there is no explanation of this in the Tableau Help.

            • 3. Re: Attribute?
              Jonathan Drummey

              The way ATTR() was described to me by Joe Mako is that it runs something like "If MIN([field]) = MAX([field]) Then return [field]), so it ends up being one number. Two ways it's useful:

               

              - Tableau uses everything in the Level of Detail shelf as part of the query, so doing as much aggregation as possible on those values can speed those up. If you know there will only be one value, then applying ATTR() to a dimension or measure there can make your view a bit faster.

               

              - Sometimes I have a single value for all rows in the database. Applying ATTR() to that value makes sure that Tableau won't try to do any sums or other aggregations on it.

               

              Jonathan

              3 of 3 people found this helpful
              • 4. Re: Attribute?
                Joe Mako

                Building upon what Jonathan said,

                 

                The formula that the ATTR() - Attribute aggregation uses is close to:

                 

                 

                IF MIN([field]) = MAX([field]) THEN MIN([field]) ELSE "*" END


                 

                This formula is evaluated in Tableau after the data is returned from the initial query, Tableau will query the database for both MIN([field]) and MAX([field]), where the "*" is a special value and if you use a comparison operator to try to detect it, the result is "unknown", kind of like when when using a comparison operator with a null value.

                 

                In most cases performing an aggregation is quicker than adding a dimension to the group by clause. I recommend looking at your log files and seeing the SQL that Tableau generates with a Dimension pill or an ATTR() aggregation of the pill.

                • 5. Re: Attribute?
                  Robert Morton

                  Hi Joe,

                  Your analysis is correct. An additional note: the '*' is actually a NULL value, but it's a special type of NULL which means "Many Values". The '*' is just a visual cue for this type of NULL, just like '#Error#' is a cue for a different type of NULL which arises from computational errors (e.g. division by zero).

                  -Robert

                  • 6. Re: Attribute?
                    Dimitri.B

                    Guys, although it is good to know how attribute cogs and gears work inside Tableau, can someone suggest a few good examples when attribute is useful or indispensable?

                    • 7. Re: Attribute?
                      Robert Morton

                      Hi Dimitri,

                       

                      The Attribute aggregation is a very useful aggregate for working with dimensions. In particular when performing data blending, all fields from the Secondary data source must be aggregated to the level of detail dictated by the dimensions in play from the Primary data source. Aggregation is a natural concept for measures, but can get tricky for dimensions. The Attribute aggregation is a natural way of using coarse-grained dimensional values from a secondary, whereas fine-grained dimensional attributes from the secondary may appear as '*' (NULL) if they cannot be succinctly representing by a single value for the given level of detail. Described in more traditional terms, using data blending and the Attribute aggregation is a way of integrating two data sets without risking a cartesian product.

                       

                      Another great use case for the Attribute aggregation is within Table Calcs, since many window functions require an aggregate expression. As with blending, NULLs may appear when a dimension has multiple values within a given table calc partition.

                       

                      Last, it's worth noting that Attribute is interpreted locally within Tableau (though it relies on MIN/MAX results from the remote data source). Since it is a local operation, any filters involving ATTR() are processed locally, which means they are processed after the remote database filters.

                       

                      -Robert

                      • 8. Re: Attribute?
                        Dimitri.B

                        Thank you, Robert. By the way, I couldn't find any info on attributes in Tableau help. I think the topic deserves a dedicated section.

                        • 9. Re: Attribute?
                          matt.lukoff.0

                          Robert,

                           

                          How can I change the Attribute "label" of my secondary data source so that I can compare it apples to apples with the dimensions of my primary source using the linked primary key?

                           

                          Thanks,

                           

                          Matt

                          • 10. Re: Attribute?
                            Robert Morton

                            Hi Matt,

                            I don't understand what you mean by "label". What kinds of values are you trying to compare? Are you performing this comparison visually or via calculated fields?

                            -Robert

                            • 11. Re: Attribute?
                              matt.lukoff.0

                              Hey Robert,

                               

                              Sorry about the confusion. By label I simply mean that one the dimensions from my secondary data file came in "defined as" attributes rather then dimensions. In doing the blending I want to view the dimensions of the primary file and the secondary file side by side.

                               

                              Matt

                              • 12. Re: Attribute?
                                Robert Morton

                                Hi Matt,

                                 

                                You can only use attribute dimensions from a secondary data source, i.e. dimensions which appear as ATTR([dimension name]) in the viz. You cannot currently use data from a secondary data source which is at a finer granularity than the level of detail of the visualization itself. Does this address your question?

                                 

                                -Robert

                                • 13. Re: Attribute?
                                  matt.lukoff.0

                                  Robert,

                                   

                                  No, I still don't see an answer that makes sense so let me try rephrasing my question:

                                   

                                  1. Is there a way to see dimension x from data source 1 and dimension y from data source 2 (and their metrics), all together in one visualization (without jockeying the data offline before it goes into Tableau)?

                                   

                                  2. If so how?

                                   

                                  Hope that's clearer - thanks for taking the time to help!

                                   

                                  BTW: Before I found this thread I had opened a new one and I see that Alex K just replied asking me to post the tbwx, which I will do: http://community.tableau.com/message/175158#175158. So feel free to reply where you wish.

                                  • 14. Re: Attribute?
                                    Lee Feinberg

                                    Robert,

                                     

                                    I have a feeling there are some great ideas in your comments.  Can you provide a workbook to show these concepts in action -- especially your point about ATTR in table calcs. That would help a lot.

                                     

                                    Thanks,
                                    Lee