KNOWLEDGE BASE

How to Change the Axis Range to Specified Values by Switching the Options of a Parameter


Published: 20 Oct 2023
Last Modified Date: 23 Oct 2023

Question

How to change the axis ranger to a specified value by switching the options of a parameter.
For example, make the max value of x axis range to be 1000 when selecting "Binders" from sub-category filter,
and make the max value of x axis range to be 2000 when selecting "Bookcase" from sub-category filter,
and don't change the max value of x axis range when selecting other options.

Environment

  • Tableau Desktop

Answer

1. Create a plot chart with [Sales] on Columns Shelf and [Profit] on Row Shelf.
* Please check the [Original View] worksheet in sample workbook attached.

2. Create a parameter named [Sub-category Parameter] and input sub-category values into it.
User-added image

3. Create a calculation fields named [Selected Subcategory] including calculations as below.
[Sub-Category Parameter]=[Sub-Category]

4. Add  [Selected Subcategory] to filter shelf and select "True" only.

5. Create a calculation fields named [X-axis(Max)] including calculations as below.

IF [Sub-Category]="Binders" THEN
    IIF([Sales]>1000,1000,[Sales])
ELSEIF [Sub-Category]="Bookcases" THEN
    IIF([Sales]>2000,2000,[Sales])
ELSE [Sales]
END

6. Add  [X-axis(Max)] to Columns Shelf and delete [Sales] fields.

7. Create a calculation fields named [Hide fields by color ] to include calculations like below.

IF ([Sub-Category]="Binders" AND [X-axis(Max)]=1000) OR ([Sub-Category]="Bookcases" AND [X-axis(Max)]=2000) THEN "Hide"
ELSE "Display"
END


8. Add [Hide fields by color ] to [Color] mark card and set the color of [Hide] to be white to hide these marks from the view.
 User-added image
User-added image

9.Change the options of the parameter and check the results.
*please refer to [Sample] sheet in the sample workbook attached.
Did this article resolve the issue?