Swap different views on a single sheet

Written by: Ivett Kovács

Swapping views on a sheet

Learn how to reveal and hide different aspects of information on a single sheet using a parameter in Tableau. Follow this step-by-step guide and take your visualization to the next level!

A quick note: This post was originally published some time ago on DataViz.Love, our old blog. We have moved it here for preservation with the approval of the author(s).

I am sure everyone knows and have already used the view/sheet selection trick controlled by a parameter in one of their own Tableau projects. I was wondering if we could reveal/hide different aspects of the information on a single sheet.

Let me show an example.

Gif of view swapping

If you swipe the line on this visualization you will be able to change the view. You can reveal/hide the different layouts. You can compare individual data points on a simple bar chart and at the same time, you can simultaneously compare sales totals and notice sharp changes at the segment level on a stacked bar chart.

Step #1: Make a Bar Chart

Connect to the Superstore data and build a simple bar chart that displays sales per month.

  • Put the Continous Month(Order Date) to Columns
  • Put Sales to Rows
Making a bar chart

Step #2: Create a parameter based on the x-axis

Let’s create the parameter that will help Tableau to change the two views. This Parameter selection will be based on the x-axis. In this case, I will refer to the Month(Order Date) field.

  • Set the Minimum and Maximum range
  • Step size = 1 Month
Create a parameter based on the X-axis

Step #3: Modify the bar chart based on the value of date parameter

Bar Chart

IF DATETRUNC(‘month’, [Order Date])>=[Date Parameter]
THEN [Sales]
  • Replace the SUM(Sales) field on Rows to this Bar Chart calculation
Modify the bar chart based on the value of the date parameter

Step #4: Add the date parameter to the chart as a reference line

Add the date parameter to the chart as a reference line

The result is:

Result of adding the reference line


Stack Bar Chart

IF DATETRUNC(‘month’, [Order Date])<[Date Parameter]
THEN [Sales]
  • Add this Stacked Bar Chart calculation next to the Bar Chart field on Rows
  • Make it Dual Axis.
Defining the stacked view
  • Syncronize them
  • Add Segment to Color Mark

Adding Segment to Color

And enjoy your result!

If you have any questions, reach out on Twitter @IvettAlexa

about the author

  • Ivett Kovács

    I love taking datasets into beautiful and informative visualizations. Besides data, I am also very passionate about traveling, surfing, cooking and exploring the outdoors with my dog.

See more posts