Tableau Tips: How to collapse charts in Tableau?

Priyanka Dobhal
3 min readMay 9, 2021

If you’ve been working with the Tableau version before 2019.2, you must have used a parameter swapping method. From 2019.2 onwards, Tableau has introduced Show/Hide containers which can also be used to swap worksheets.
But in this blog, I’ll be talking about swapping worksheets using parameters only and a challenge that I had faced initially.

How does Parameter swapping work?

Taking an example, you have two worksheets with bar charts: Bar -1 and Bar -2

Place them in a vertical/horizontal container.

Quick Tip: It’s good to name your containers. It comes in handy when you’re navigating through a bunch of container hierarchies to locate something.

Anyways, now we have our initial setup ready. We need a parameter to switch between sheets.

We can use an integer or a string parameter, but I went with an integer (since it is better for performance)

I named the parameter p.Bar Menu

Select 1 from the parameter and assign it to Bar -1 Sheet

Similarly, select 2 from the parameter and assign it to Bar -2 worksheet.

So that’s all you need to do. Now to make the sheet swapping smooth, hide the Title of the worksheets.

Done! So this looked pretty straightforward, right? Then what sort of challenge was I talking about?

Challenge

So this goes back to 2019 when I had just started using tableau. I wanted to switch between a Treemap and Bar chart.
I followed the same steps and set it up.

When I select the Treemap chart, it collapses completely. But when I selected Bar chart, I could still see the Treemap worksheet even if it is blank.

Why does this happen? When we tried the same with bar charts, it collapses completely. You’ll see the same with Treemap, shapes, text boxes, etc.

Can you think of a reason?

Let me share my theory on this.

But first, think for a moment, how does a bar chart differ from a treemap in construction?

A bar chart has a dimension either in a row or column section, but a treemap doesn't.

So ideally if I have a dimension on a row or column it should work, right?

To test this out, I added a Dummy dimension on the rows. Now hide this dimension.

Let’s take a look at the dashboard again.

Voila! The Treemap collapsed completely this time. Now I have done a similar test on multiple other charts that don’t have anything of row or column and it worked well.

Want to see more such examples? You can find the sample workbook on my Tableau Public Page: Tableau Public: How to sheet swap?

Feel free to download and try it yourself.

Did this help you? Would love to hear from you.

Thanks for the read :)

--

--