Change values in a filter based on Parameter selection in Tableau
Parameters provide good functionality in Tableau and help in creating interactive dashboards. In this article, we will learn how to change values in a filter, based on Parameter selection in Tableau.
I will first explain what I mean by changing the values in a filter, based on a parameter selection.
Suppose, giving a dataset, we have a list of customers who purchase items from online, in-store and by making phone calls. The data source contains sales for each of these purchases.
In this scenario, based on the selection made in parameter ‘Type of Order’, values in the filter ‘Customers’ should change.
In the above figure, when ‘Type of Order’ is Online, names of ‘Customers’ who made online purchase will be displayed.
How to change values in a filter based on Parameter selection
To achieve the above functionality, follow the below steps. This example uses the following dataset:
Steps:
- Create a parameter – ‘Type of Order’ for each order types – Online, Store and Call. Learn how to create a parameter
2. Create a calculated field – ‘Customers’ to use this parameter. In the below code, Type of Order is the parameter created in the previous step.
IF [Type of Order] = “Online” THEN [Online]
ELSEIF [Type of Order] = “Store” THEN [Store]
ELSEIF [Type of Order] = “Call” THEN [Call]
END
3. Create another calculated field – ‘Sales Display’ to display Sales for each ‘Type of Order’ parameter in the chart
If [Type of Order] = ‘Online’ then [Sales (Online)]
ELSEIF [Type of Order] = ‘Store’ then [Sales (Store)]
ELSEIF [Type of Order] = ‘Call’ then [Sales]
End
4. Create a bar chart by using the calculated field ‘Customers’ on Rows and ‘Sales Display’ on Columns.
5. Right-click on calculated field Customers and select Show Filters. More on filters.
Right-click on the parameter Type of Order and select Show Parameter.
If you select ‘Store’ in ‘Type of Order’ parameter, the ‘Customers’ list and chart will display the Store Sales.
About the Author
Chandraish Sinha has 20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau,Power BI, and Qlik. Checkout his Amazon Author profile.
His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.
Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.
He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.
He blogs regularly on various IT topics. Check them out in the links given below: