I have been asked a few times on how we can add the ability to swap worksheets dynamically. Here is a nice and simple quick tip on selecting worksheets using a Parameters.
We will start by loading the following data into Tableau Desktop / Tableau public.
Note: If you have Tableau Desktop, you can use the Sample data source, but if you are using Tableau Public, download and load the following data source.
We only need to create the following Parameter and Calculation Fields:
@Sheet Selector Parameter
- Set the Name to @Sheet Selector
- Set the Data type to String
- Set the Allowable values to List
- Set the Value to Sales Over Time
- Set the Value to Sales by State
- Set the Current value to Sales Over Time
Sheet Filter = Sales by State
[@Sheet Selector] = "Sales by State"
Sheet Filter = Sales Over Time
[@Sheet Selector] = "Sales Over Time"
With this done, let us start creating our data visualisation.
We will now build our worksheets:
Sales Over Time
- Create a Worksheet Called Sales Over Time
- Change the Mark Type to Line
- Drag Order Date to the Columns Shelf
- Right-click on this pill and convert to a Continuous Month
- Drag Sales onto the Row Shelf
- Drag Order Date onto the Colour Mark
- Drag Sheet Filter = Sales Over Time to True
You should have the following:
Sales by State
- Create a New Worksheet called Sales by State
- Change the @Sheet Selector to Sales by State
- Drag State onto the Label Mark
- Drag Sales onto the Size Mark
- Drag Sales onto the Colour Mark
- Drag Sheet Filter = Sales by State to True
You should now see the following:
Now add both to a Dashboard:
- Create a New Dashboard called Dynamic Worksheet Selector
- Select Floating and add a Horizontal Container onto the Dashboard
- Select Tiled and add both of our worksheets onto this Horizontal Container
- Change the View from Standard to Entire View for Both Worksheets
- Hide the Title for both Worksheets
Now if you change the Parameter, you should be able to switch between Sales Over Time and Sales by State using the Parameter.
Note: be sure that you turn on animations for some fun and a really good effect
and boom, we are done with this Tableau Quick Tip, and I hope you had some seriously good fun; as always, you can find my data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/DynamicReplaceWorksheet/DynamicReplaceWorksheet
I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualization, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.
If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy: https://www.patreon.com/tableaumagic