KNOWLEDGE BASE

Extending the Range of An Axis


Published: 30 Apr 2015
Last Modified Date: 23 Nov 2016

Question

How to dynamically extend the range of an axis.

Environment

Tableau Desktop

Answer

It is possible to use reference lines in order to extend an axis without using a 'fixed' range in the 'Edit Axis' menu. The following instructions can be reviewed in the attached workbook.

Step 1 : Build the View

  1. Right click and drag Order Date to Columns and select Quarter (Order Date) as a continuous field. 
  2. Drag Sales to Rows
  3. Drag Profit to Rows.
  4. Right click on Profit and select Dual Axis.
  5. On the Profit Axis, right click and select Synchronize Axis.
  6. On the Sales Mark Card, change the Chart to Bars.

Step 2: Create a new calculated fields for Canada

  1. Select Analysis > Create Calculated Field 
  2. In the Create Calculated Field dialog box, do the following and click OK:
  3. Name the field. In the example, this field is called "Reference Line" and enter the following formula: 
    DATEADD('year',5,{ MAX([Order Date]) })
    Note that this can be adjusted by using different formulas to fix the range anchored to the min/max of the data set (entire or view).

Step 3: Add the reference line to the view

  1. Right-click and drag "Reference Line" to Details on the All Marks
  2. Select Year (Reference Line) as a continuous field.     
  3. Right click the Quarter (Order Date) Axis and select Add a reference line 
  4. Set the Value to use the calculated field (Reference line in this example), set Label to 'None' and Line to 'None'.
  5. (Optional) Click on Tooltip and remove the reference to the newly created date field. 
  6. (Optional) It is possible to make the amount of time units in the 'DATEADD' function a parameter. 

Additional Information

To view these steps in action, see the video below: 
Did this article resolve the issue?