KNOWLEDGE BASE

## Diagonal Reference Line

Published: 15 Apr 2014

### Question

How to create a diagonal or custom reference line.

### Environment

Tableau Desktop

#### Option 1: Use A Calculated Field

The following instructions use Superstore sample data can be reviewed in the workbook attached below: 45 degree reference line.twbx

### Step 1: Set up the view

1. Drag Profit to Columns.
2. Drag Sales to Rows.
3. Select Analysis > Aggregate Measures.
4. Select Analysis > Create Calculated Field.
5. In the Calculated Field dialog, enter the following, then click OK:
• Name the calculated field "Reference Line".
• In the Formula field, enter `[Profit]`.
6. Select the desired field and drag it to the Color card of the All Mark. In this example, the Sales measure is used.

### Step 2: Set up the reference line

1. Drag Reference Line to Rows.
2. Right-click the Reference Line measure and select Dual Axis.
3. Right-click the Reference Line axis and select Synchronize Axis.
4. On the Marks card for All, remove Measure Names from Color
5. On the Marks card for SUM(Reference Line), change the mark type from Automatic to Line.
6. Right-click on the line and select Trend Lines > Show Trend Lines.
7. Click Color on the Marks card for SUM(Reference Line) and change the transparency to zero.

### Step 3: Set up the axes

1. Right-click the Profit axis, select Edit Axis.
2. In the Edit Axis dialog box:
• Select Fixed Range.
• Change the Start value to -20,000.
• Change the End value to 125,000
3. Click OK.
4. Edit the Sales axis and choose the same range as the Profit axis.
5. Right-click Reference Line on the Rows shelf and uncheck for Show Header.

To view these steps in action, see the video below:

#### Option 2: Use a Background Image

The following instructions use Superstore sample data, and can be reviewed in the attached workbook: Diag_ref_line.twbx
1. Save a .jpg file of a diagonal line.
Note: attached file Diag_line2.jpg is a cropped screen-shot of the view created in Option 1, with grid lines removed and all marks set to transparent.