console.log("script ran")

dashboard / LEARN / Other / Tableau

Swap different views on a single sheet


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

Let me show an example.

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
  • Sales to Rows

STEP #2: Create a Parameter based on X-axis

Let’s create the parameter that will help Tableau to change the 2 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

STEP #3: Modify the  bar chart based on the value of Date Parameter

Bar Chart

IF DATETRUNC(‘month’, [Order Date])>=[Date Parameter]
    THEN [Sales]
       ELSE 0

  • Replace the SUM(Sales) field on Rows to this Bar Chart calculation   

STEP #4: Add the Date Parameter to the chart as a reference line

The result is:

STEP #4: Define the Stacked view

Stack Bar Chart

IF DATETRUNC(‘month’, [Order Date])<[Date Parameter]
    THEN [Sales]
       ELSE 0

  • Add this Stacked Bar Chart calculation next to the Bar Chart field on Rows
  • Make Dual Axis

  • Synchronize them
  • Add Segment to Color Mark

And enjoy your result

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



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.

Your email address will not be published.