Monday, January 28, 2013

Working with Sets in Tableau

Today, we will look at Tableau's "Sets" feature, which allows you to alter the data displayed in your graphs.  As usual, we will use the Superstore Sales sample data set in Tableau.

Step 1:

  • Create a worksheet with 2 non-hierarchical fields
Profit by Region and Ship Mode
As you can see, we have a "Cartesian Product" of Region and Ship Mode.  This means that every combination of Region and Ship Mode exists.  But, what if we wanted the combination of these fields to be a single field instead of two.  In SQL, you could concatenate the fields together; however, tableau has a better way.

Step 2:

  • CTRL-Select "Region" and "Ship Mode" in the Dimensions pane.  Both should be highlighted.
  • Right-Click one of the Selected Fields and Select "Create Set"
  • Type "Region and Ship Mode" in the Name Box
  • Find the Set in the "Sets" Pane in the bottom-left corner
  • Add this set to the graph
Profit by Region and Ship Mode, with Set
We see that every row has a distinct value in the set.  While this is merely cosmetic for this graph, you can now implement more complex filtering and sorting based on combinations of fields.  We will see many more great uses for this feature later.  Thanks for reading.

Brad Llewellyn
Associate Consultant
Mariner, LLC
llewellyn.wb@gmail.com
https://www.linkedin.com/in/bradllewellyn

4 comments:

  1. Brad,Thanks for your knowledge sharing blogs!

    I was having some trouble understanding one issue while trying to create a set using the Sample excel files in Tableau 8, hope you can clarify it.
    I plotted Profit (Y axis), Sales(X axis) and added the filter to show data only for Central Region and Furniture Product Category. Now I added Customer Name in Detail Level and Label.I then removed the aggregation from the Analysis menu to show the scatter plot at the Customer Level. Now I enabled a basic trend line and tried to select few customers appearing below that Trend Line. I drew an area around them and right click on any one of the customers. But I am not getting the option to create a set there, only grouping. The thing is that if I go to the Customer Name in the dimension pane and right click the dimension to create a set, I am getting the option to create one set.
    So, I am not able to understand why cannot I get a create set option in the view to create a static set of manually select Customers whereas I can see the option to create the set from the dimension pane.
    Can you please let me know the reason for such behaviour if you are aware of it?

    TIA,
    Ashish

    ReplyDelete
    Replies
    1. Ashish,

      In this case, you are only allowed to add these members to a pre-existing set. I'm not sure why this is. A simple workaround is to right-click [Customer] in the Dimensions Shelf and create an empty group. Then, you can use the chart to add members to this group.

      Delete
    2. Thanks Brad! I'll try this and see how this works.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete