Last Modified Date: 20 Jul 2023
Environment
Tableau DesktopAnswer
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.twbxStep 1: Set up the view
- Drag Profit to Columns.
- Drag Sales to Rows.
- Select Analysis > Aggregate Measures.
- Select Analysis > Create Calculated Field.
- In the Calculated Field dialog, enter the following, then click OK:
- Name the calculated field "Reference Line".
- In the Formula field, enter
[Profit]
.
- 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
- Drag Reference Line to Rows.
- Right-click the Reference Line measure and select Dual Axis.
- Right-click the Reference Line axis and select Synchronize Axis.
- On the Marks card for All, remove Measure Names from Color
- On the Marks card for SUM(Reference Line), change the mark type from Automatic to Line.
- Right-click on the line and select Trend Lines > Show Trend Lines.
- Click Color on the Marks card for SUM(Reference Line) and change the transparency to zero.
Step 3: Set up the axes
- Right-click the Profit axis, select Edit Axis.
- In the Edit Axis dialog box:
- Select Fixed Range.
- Change the Start value to -20,000.
- Change the End value to 125,000
- Click OK.
- Edit the Sales axis and choose the same range as the Profit axis.
- 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- 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. - Add the image to your view as a background image. For more information, see Adding Background Images.
Additional Information
- When using Option 1, the marks for the axis creating the diagonal line are selectable, which can lead to confusion with interactive views.
- When using a background image as in Option 2, you can enter two points to scale the diagonal line behind the scatter plot.
- Draw custom 45 degree line to compare against T's calculated trend line?
- Creating a 45 Degree Reference Line in a Tableau Scatter Plot (without SQL!)
- To voice your support for the inclusion of this enhancement in a future product release, add your vote to the following Community Idea: continuous (angled) reference lines & bands
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials
Related Links
Results 1-2 of 2
Trending Articles
Results 1-3 of 49