What is Parameter?
A parameter is a workbook variable such as a number, date, or string that can replace a constant value in a calculation, filter, or reference line. This is definition from Tableau documentation.
Lets see some simple definition
A parameter is a limit- from vocabulary.com
A set of facts or a fixed limit that establishes or limits how something can or must happen or be done: from dictionary.cambridge.org
Parameters are values that users can change when interacting with a view.
They add versatility to your visualizations.
A Tableau parameter allows you or your end-user to change the content that appears in worksheets and dashboards.
Within Tableau, wherever you are entering a constant value, there’s a great chance you can use a parameter instead. It is like instead of hardcoding we can use a variable (parameter) to make it dynamic or flexible.
Its like taking orders in Restaurants, waiter will ask customers what would you like order and according to order it will prepare food.
Just like that, parameter will behave according to end users requirements.
Once it created it will sit in data pane just like any dimensions , measures or calculated fields. It could be a number ,string or date type and can be used in any sheet .
parameters might sound like filters but there are lot different from each other.
How are parameters different from filters?
primary role of filter is to narrow down data, which allows both basic and complex filtering base on specific Order of Operation.
A Parameter is independent of the data source while filters are not.
A Parameter's scope is at the Workbook level, meaning it can be seen by any worksheet in the same workbook while filters are by default is at the Worksheet level. However we can apply our filters to different worksheets if we want to.
Parameters can be used in calculated fields where as filters cannot be embedded inside expressions.
Filters in form can have multi-select values while parameters are single select base on a list or require user input.
Actions are available for parameters but not for filters. Parameter actions enable changes in your view, by hover, select or menu.
If you will use the same data set throughout your visualization that means data is not going to change then you should use parameters. Parameters doesn’t hit the data so overall your process will be fast.
Filters on static data slowed down the process.
Typical steps to create parameters:
1. Create Parameter
There are a couple of ways to build a parameter. The most direct is to right-click on the white space in your data pane and select Create Parameter.
Or right click on any field and select create parameter
Or in data pane there is small drop down button near search bar, once you drop down that button you will see create parameter option.
2. Show control (optional)
Right-click on the desired parameter in your Parameters section of your Data pane. Select Show Parameter Control, and your parameter control will appear in your visualization just like a filter control:
It will look like below picture. It will in the upper right corner.
3.Use Your Parameter in Calculation:
There are a lot of different ways to use parameters. some of use cases that are filters, bins, reference lines, calculated fields. Top Customers and Profit Bib size are by default parameters in sample super store dataset.
4.Use parameters in view
The last piece is using the calculation within your view. For instance, if your parameter is a top # of a list, then you’d use it in a filter. If your parameter was different bin sizes, you’d use it in a histogram.
There are four standard use cases for parameters.
Filters
Bins
Reference lines
Calculated fields
lets try the first use case of filter to find top products.
Here instead of saying top 10 or top 5 . we will create parameter for top N products. Remember no hardcoding.
Along with dynamic visualization we will create dynamic title like this .This 20 number will change as we change our parameter.
Follow these steps
Let’s look at top Products by Order Quantity. Drag Product Name to rows and Order Quantity to columns (sum(order quantity)).
Now drag Product Name to the filter shelf.
A filter box will appear with a number of tabs along the top. Each of those allows you flexibility in how you filter. For now, go to the Top tab.
Choose “By Field.”
To create the Tableau parameter, select keep Top if you want to find top or you cab change to bottom a well. there is drop down in rectangle where 10 is written. change it to create parameter.
Hit ok
7. Now name your parameter as "Top N Products"
8. Set min to 10 and max to 50 in the parameter . Set the step size to 5
9. Hit ok. now you can see this parameter at left bottom corner in data pane.
10. Right click on Top N products and click show parameter
11. To make the title interactive , edit title write Top insert from drop down and select Top N parameter and complete the sentence with products
12. select ok.
13. your visualization will look like this.
14. I just dragged my parameter below marks card to save space.
I will continue other use cases in next blog.
I will post my Tableau workbook along with some other use cases.