Monday, March 24, 2014

Partial Highlighting on Charts in Tableau

Today, we will talk about a concept that we're calling "Partial Highlighting."  In Tableau, you can link dashboards in a number of ways on a dashboard.  When you click on one chart, you can have the values in another chart either be highlighted or be filtered.  Let's examine these two aspects individually.  As usual, we will the Superstore Sales sample data set from Tableau.

First, when you use a highlight action in Tableau, it will only highlight the same values in the same field that you highlighted.
Highlighting
As you can see, when we click on Jumbo Box, the Jumbo Box values in Sheets 1 and 3 are highlighting.  However, there is no highlighting on Sheet 2 because the Container field is not in the chart.  Let's move on to filtering.

When you use a filter action in Tableau, it will add a filter to the chart so that only the values with the values you selected are shown.
Filtering
Now, when we click on Jumbo Box, the other Container values disappear completely from the other charts.  These are extremely useful options.  However, what if I wanted to click on Jumbo Box and have the bars in Sheet 2 highlight the portion of each bar that corresponds to Container = Jumbo Box?  Power View, the visual analytics portion of Microsoft's Power BI stack, actually does this very well.
Partial Highlighting
As you can see, when I click on Jumbo Drum, the top right bar graph highlights the appropriate portion, while still allowing us to see what the total was so that we don't lose perspective.  We recently had an epiphany about accomplishing this in Tableau and it's actually pretty easy!

In order to accomplish this, we're going what's known as a "Scaffold Data Source."  This idea was pioneered by Joe Mako.  You can find out more information by watching his "Think Data Thursday" presentation here.  Let's start by creating a regular bar graph.
Sales by Order Priority
If we place this on a dashboard using the filter action, then this chart will filter entirely based on another selection.  Next, we need to duplicate our data source so that we have two copies of it within Tableau.
Duplicate Data Source
Now, let's use the dual-axis feature to place the same set of bars on this chart again.  But, this time we're going to use SUM( [Sales] ) from our duplicated data source.
Sales by Order Priority (Hidden Dual Axis)
We renamed the [Sales] field in the secondary data source so that we knew which [Sales] was the primary.  Then, we created a dual axis bar graph, made sure the primary Sales was in front, synchronized the axes, hid the Blended Sales axis and colored the Blended Sales Bar bar a lighter shade of blue.  This way, it looks exactly like a regular bar graph.  Next, we need to make it so that these data sources blend on every field EXCEPT Container.
Unlinking Container
Once we do this, the secondary data source will not be filtered if we try to filter the primary data source on Container.  See where this is going?
Partial Highlighting (Tableau)
Now, when we click on Jumbo Drum in Sheet 1, the primary bar filters for Sheet 4.  However, since the secondary data source is not linked over Container, the underlying bar does not filter.  This gives the appearance of partial filtering!  The really cool thing about this technique is that you can do it for lots of other types of charts.  All you need a little imagination.  Thanks for reading.  We hope you found this informative.

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

7 comments:

  1. Hi Brad , Was interested to learn this trick and went on trying it, But some how i dont see any change in the color of my bar graph in the dashboard.

    I am attaching the link here
    http://public.tableausoftware.com/views/partialhighlight/Sheet1?amp;:embed=y&:display_count=no

    ReplyDelete
    Replies
    1. Vishwakar,

      Sorry it took me so long to respond. The issue was that you needed to right-click on the secondary axis (the top one) and click "Move Marks to Back". Your secondary data marks were obscuring the primary data marks so you couldn't see anything. I've posted the updated copy at

      http://www.speedyshare.com/NxFer/partial-highlight.twbx

      Delete
  2. Firstly, thanks a lot for this post. I was under the impression that the top and pretty expensive VA software would make this intuitive and easy to do. Definitely not. As a new Tableau user I would not be able to figure this out by myself. Their documentation also did not help in my quest for this.

    ReplyDelete
    Replies
    1. You are correct that this is just one of the deficiencies in Tableau. No tool is perfect or suited for every task. The goal is to find the one that accomplishes the goal you have. Thanks for commenting!

      Delete
  3. Do the linking fields actually have to be "turned on" in the data window, or did you just remove Container from the list of fields in the "Edit Relationships" window? I'm not clear on this step.

    ReplyDelete
  4. I was able to get it working. I was confused by the line "Next, we need to make it so that these data sources blend on every field EXCEPT Container" Technically, we aren't blending on these fields -- we just need to make sure we are blending on Order Priority and NOT Container, correct? Is it possible for you to include workbook examples with your posts? Cheers, and thanks for posting!

    ReplyDelete
    Replies
    1. Thanks for the kind words. Perhaps I will start posting my blog examples to Tableau Public!

      Delete