Tableau Tip #4: Using a parameter to change the view in a dashboard (part 3)

by Bethany Fox

In my previous blog…

I explained how to create a sheet which provides one colour legend for all sheets in a dashboard, which changes depending on the view selected in the parameter; the final dashboard can be found here. This worked well when the colour legend was representing the same measure in each view, but what if you want two different colour legends which represent different measures or dimensions?

What’s the problem?

Unfortunately, you can’t filter out legends from the view using a parameter like you can with worksheets. Consider two worksheets – a map with points coloured by profit and sized by total sales, and a stacked bar chart showing total sales coloured by region. Because Region is a discrete field, when the dashboard is showing the map, the Region colour legend for the bar chart disappears. However, when the dashboard is showing the stacked bar chart, the profit colour legend for the map is still visible, but shows only one colour for the NULL values. So if you have a dashboard which switches between a sheet with Profit on colour, and another with Region on colour, you need a little ‘work-around’ to show just one at a time.

Here’s the trick…

  1. On a new worksheet, create a new calculated field called ‘Blank’ (or whatever else you fancy), which contains nothing inside but opening and closing speech marks, like so:blank-2
  2. Drag this new field in to the view, hold down the CNTRL key and drag on to Text in the Marks Card.
  3. Hide the field labels, and format the view to remove the row dividers. Your final sheet should look like it has nothing in the view but the sheet name.
  4. Next, drag this new worksheet on to your dashboard as a floating object and select ‘Entire View’ so the white space takes over the whole object, leaving no part of it transparent.
  5. Size the object to be slightly larger than your measure colour legend, and place it on top.
  6. Go back to the ‘Blank’ worksheet and drag the calculated field which works with the parameter on to your filters.
  7. Making sure that the parameter value selected is the view corresponding to the colour legend you want to hide (i.e. the measure legend, in this case showing profit for the map worksheet), select exclude, and tick the view shown in the filter.
  8. Go back to your dashboard and check that the right colour legend shows for each worksheet selected in the parameter.

And you’re done! Follow the video below to see the above steps in action:

[youtube https://www.youtube.com/watch?v=WEBKQ10w8HI&w=560&h=315]