Using parameter to swap between different visualizations (e.g. between bar and area chart)
In one of the previous articles in this platform, I showed you how to swap between views using a parameter and a layout container. This approach was a little bit a process and required us to create a dashboard to materialize that.
See the article: Using parameter and layout container to swap between views.
In this article, I would like us to take a different approach – whereby instead of using parameter, layout container and dashboard layout. We are going to use a parameter and a calculated field to enable viz swapping within the worksheet level. For this case we are going to create a view in which users can swap between a bar chart view and an area chart view.
Create a parameter.
Create a string parameter ‘Select chart type’.
Useful: Learn how to create parameters
Create the first view – a bar chart.
To create the first view, lets create the calculation ‘Bar chart view’.
Create the view by dragging Sub-category to the columns and the calculation ‘Bar chart view’ to the rows. Choose Bar chart under the marks card.
Create the second view – an area chart.
To do that create the calculation ‘Area chart view’ as shown below.
Drag this calculation to the view, make the chart dual axis and synchronize the axis.
Under marks card of the second view – ‘Area chart view’, choose ‘Area chart’.
Show the parameter control and select ‘Area’.
Note now the view can change from Bar to Area chart and vice-versa based on your selection on the parameter control.
In a nutshell, that is the second way you can swap between different visualizations using a parameter and a calculated field.
I hope this article was somewhat helpful to you. To receive more of the Tableau tips and tricks, kindly join our mailing list by subscribing below.
Thank you for reading.