top of page
Swapna Lakhpati

Tableau Parameters - Easy way -Part 2

There is a part 1 of this blog which explain all basic information about parameters and a simple example. That will help clear concept of parameter.

What is parameter?

Parameter is a value that can be changed by the user interacting with a view, rather than your visualization using a constant value.

Parameters allow you to give your users control over the viz.

Where to Use parameters?

Top N / Bottom N

User controlled thresholds

Dynamic fields, axis , titles etc.

Filtering across different Data sources

What are the steps to use Parameters?

Create Parameters

Use parameters in either calculated fields, reference line, sets or filters


Lets see some practical examples:

* Dynamic reference line

We are using superstore Dataset which comes with Tableau software.

steps

1. Right click drag > Order date> pick continuous order dates to columns > green colored



2. sales to rows

As you can see a line chart is not useful or clear. If we want to see a particular date sale then it is difficult to see.

so to make the things simple lets

3. create a parameter


4. Name the parameter as Pick a Date or select Date something appropriate.

5. change data type to Date.

6. Current date is default today's date (current day date)

7. change to a date to any, I choose I 2nd Jan 2020.

8. Hit ok

(my Dataset has 2019 to 2022 four years sales data.)

9. we can see parameter at left bottom corner.


10. Right click on "Pick a Date " parameter and select show parameter.

11 .Change date from parameter and observe the line chart , nothing changes as we change date, it means

we need to activate the parameter. to do so we need to use it in either calculated field, reference line, set or filter.

12.lets use it in reference line

13.Go to Analytics select reference line.



14. Drag to day of order date



15.Something like this window will appear on your screen.


16. we need to do some changes like drop down value and select pick a Day parameter we created, Label to None, Line to dotted if you want . It will look like below.

17. Hit ok

18. now our parameter is activated and Now the reference line will move as we change the date from parameter.

19. this is a great way to go on particular date

reference line is on same date as the date we pick from parameter

now lets use this parameter in calculated field,

20.create calculated field to see our picked date is older than order date

lets name it as

Is older than Picked date. This is calculated field will be Boolean field will result in true or false.




21. Drop this field in colors , and we can see orders before picked date and after picked date in two different color.

As we change date from parameter ,colors also follow.


Example :Sales forecast

  1. Sub-category on rows and sales in column. sort the sales in descending order. Here we want to see forecast of sales we can use parameters

2. Create parameter name it "Sales Forecast"

3. data type> float , Display format > percentage > decimal points > 0 or keep 2 its up to you.

4.current value 1

5. select radio button range

6. Add minimum, maximum and range values to -1, 1, 0.05 respectively

7. Hit ok

8. Sales Forecast > show parameter

9. Time to use parameter

10. create calculated field, Sales Forecast calculation

11.Drag this calculated field on x axis

12.we can clearly see sales and forecast sale for each subcategory.

13.To see more clear , control select measure names from rows to color (control select drag will create duplicate of that field )

14.Click T above column to get labels in one click.


15. we can see sales forecast considering percentage in parameter.

Sales Trend with selected Date

Open new worksheet , we will use both parameters together

order date > continuous>order date .day >column

sum sales> row> drop down > sum sales> quick table calculation> running total

show parameter > pick a day

show parameter > Sales Forecast

Analytics> reference line > day

create calculated field


Double click on this new calculated field

marks card> sum (sales projection) >quick table calculations> running total

Go two rows drop down second sum (sales projected) > dual axis > select line chart from marks card

right click on right side axis > synchronize axis > show head to remove that axis


*Dynamic Sorting using Parameters

  1. subcategory on rows

  2. sales> columns , profit > columns ,

  3. Right click drag Discount on column select Average (Average discount > column )


4.Create parameter to give control to user , how they want to sort, either sales, profit or discount

5 name the parameter as Sort By, data type > string

6 Select radio button list add one by one like Sales, Profit, Discount

make sure you are writing correct spelling and case.

7. Hit ok

8 .Go to Sort By parameter > show parameter

As of now you now this parameter is not active we need to wire it.

9.Create calculated field to use parameter



10. sort sub-category descending by new field Sort order

11 drop down sub-category from rows > sort > desc > by field > Sales



12. Drag new field Sort Order in column.

13.Now as we change our parameter values, it will show new chart which is exactly matches to the chart of selected parameter.

In this picture it is matching to Avg discount as we selected Discount from parameter

14. Now you can remove the Sort order field from view

15. Sort sub-category descending and by field > Sort Order


16. Now the charts will sort by selected parameter there will be no fourth chart.


17. If you want to see sales and profit in descending order and avg discount in ascending order , make a small change in calculated field Sort Order like put Negative sign in front of Avg (Discount)


sorted by sale which is descending order

sorted by Avg discount ascending



*Top N and Sort

steps:

sum of Profit , sum of sales, Avg discount in columns

product names in rows

sort product name descending , by field Sort Order

show parameter Sort By



Drop down Product Names > filter > Use all > Top

By field> top > drop down > create parameter

change field > Sort Order > ok

Name parameter as Top N, data type> integer

> Range > minimum> 5, maximum > 100 , step size 1 (optional)

show Parameter > Top N

Put Product name in filter and do these setting of filter

Top

By field > top > drop down > Top N > Sort Order > ok

Since our Minimum values was 5 and maximum 100, It will show top 5 to top 100.

If you want to change the range you can. Right click on Top N parameter and edit.

I will edit to 1 to 50


*Dynamic Dimension

Lets say, our user want to see sales against different dimensions, in that case we will not create different graphs . Instead we can create a parameter to change dimension dynamically.

  1. Sales in column , ship mode in Rows

  2. Create parameter

  3. Name select Dimension > Data Type > string > List

  4. Add dimensions to list one by one

  5. Hit Ok


show parameter " Select Dimension"

Create calculated field to activate the parameter

we can change list any time by editing parameter and we have to make changes in calculated field accordingly.

Drop the new field " Dimension Selection" on the top of exiting dimension in row. It will replace that dimension .

Now we can control dimension from the parameter and see sales with all dimensions mentioned in parameter.


we can sort " Dimension selection" by field sales, descending



* Dynamic Dimension and Measure

As we created dynamic Dimensions, similarly we can create dynamic measure as well. we already created "Sort By" parameter, which is nothing but list of sales, profit and discount measures, so we can use the same parameter here.

  1. Duplicate the pervious sheet , select "Order By " parameter and show parameter.

  2. Now look for the calculated field we created to use "Order By " parameter

  3. calculated field was " Sort Order"

4. Now Duplicate this field Right click > duplicate

5. Right click on duplicated field edit it

6. change the name as "Measure Selected"

7. Remove negative sign from Avg Discount


8. Now drop this field in columns , remove sales from column

9.change both parameters and see how the chart is changing

Cherry on a top , you might want to bring Top N parameters in views. Lets do that . Remember just by saying show parameter nothing will happen . we need to activate this Top N parameter according to our need.

  1. Filter "Dimension selection" . Drop down "Dimension Selection" from Row

  2. filter > Top > By field >Drop down select Top N > ok

3.Show "Top N" parameter. Play around all the parameters

4.Region has only 4 values so it will not show top 5 or > 5. same with ship mode.

5.Pull Sort By parameter in column so that you can see what measure ii is on x axis.

6.Right click on X axis edit , remove the title


It will look like this.


I hope you understand the parameters.

I am attaching my tableau workbook link for reference with additional Use cases.

Parameters | Tableau Public <-- link for Tableau workbook

Thank you....

44 views

Recent Posts

See All
bottom of page