Learning how to create a toggle button in Tableau is very useful when you want to make a filter between data points, switch from data visualisation to another, or show true versus false results. The toggle button practically looks like an on/off button that allows you to change the setting between two visualisations.
Let’s see how does the entire process of creating this button look like. Watch closely the tutorial here, custom-created by our colleague Serban Grecu, Data Analyst@btProvider.
If you want to implement the toggle button on your own projects, here are all the steps you must take.
In Tableau Desktop, connect to Sample – Superstore data provided by Tableau.
→Create a calculated field named “Current Year Sales”:
if YEAR([Order Date])=” Insert Year here” then [Sales] END
→Create a parameter named “Toggle Parameter” :
Data type – Integer
Allowable values – List
Under List of Values add the following values: 1 and 0
→Create another calculated field named “Prior Year Sales”:
case [Toggle Parameter] when 1 then
if YEAR([Order Date])=2015 then [Sales] END
else null end
→Create a line chart using the Current Year Sales and Prior Year Sales in a sheet called “Sales”
Drag “Order Date” to Columns and display it as Months
Drag Current Year Sales and Prior Year Sales to rows
Right-click on Prior Year Sales and select Dual Axis
Right-click on a chart axis and select Synchronize Axis
Format the chart as you see fit (remove headers, add mark labels etc)
→Create a new sheet (named “Toggle”) where you will create the visual for the toggle button
Drag “Value” to Columns and make sure it is formatted as Continuous Dimension
Drag the “Toggle Parameter” next to “Value” in the Columns bar
Format the “Value” visual as a line and change its thickness as needed
Format the “Toggle Parameter” visual as a circle and change its size as needed
Drag the “Values” to Color
→Create a New Dashboard and drag the Sales sheet and Toggle and format the tiles as needed (w w/o title, legend etc)
→Go to Dashboard -> Actions -> Add Action -> Change Parameter
Source Sheets à your New Dashboard
In the window, select the sheet where you created the toggle button (in our case, sheet “Toggle”)
Parameter à chose the “Toggle Parameter” parameter
Field à Value (Toggle sheet)
Aggregation à None
→Hit OK twice and enjoy. Happy data analysis!
Here is the Viz on Tableau Public>
We hold all possible technical and sales certifications for all products: Tableau Desktop, Tableau Server, Tableau Prep, Tableau Data Management.
With Tableau Software – the best data visualization platform – you can always understand your business or your job better. Using Tableau, you will take smart and strategic decisions and you will quickly understand the data flow, numbers and results it produces.
Are you interested in learning more about one of the best analytics tools and implementing the solution in the entire company? Contact us!
How to Retrieve and Process JSON Data from a REST API in Talend Are you working as a Data Engineer, and have you started using Talend? Maybe in one of your projects, you need to retrieve data from a REST […]
💡 Unlock the Power of Tableau for Smarter Data Decisions Are you ready to transform the way you see and use data? Tableau is more than just a data visualisation tool, it’s your gateway to interactive, intuitive, and impactful business […]
You are working at a Data Analytics company, and in one of your projects, you need to load data from a source into a target table using Talend. However, while running the Talend Job, the data will fail to load […]