KNOWLEDGE BASE

## Add a Reference Line to a Discrete Header

Published: 20 Jun 2014
Last Modified Date: 07 Dec 2020

### Issue

Unable to add a reference line to a discrete field in the view. For example, adding a reference line on a histogram.

### Environment

• Tableau Desktop

### Resolution

The directions for each example start from the corresponding "original" worksheet in the example workbook that can be downloaded from the right-hand pane of this article.

#### Option 1: Convert the discrete field to a continuous numeric or date field

1. Select Analysis > Create Calculated Field
2. In the Calculated Field dialog box that opens, do the following, and then click OK:
• Name the calculated field. In this example, the calculated field is named "Sales Bins"
• In the formula field, create a calculation similar to the following:
• `(FLOOR([Sales]/1655)*1655)`
Note: The above calculation is the same calculation that Tableau Desktop uses to generate bins. 1655 is the size of the bin.
3. Right-click [Sales Bins] in the data pane and select Convert to Dimension
4. Right-click [Sales Bins] in the data pane and select Convert to Continuous
5. Replace [Sales (bins)] with [Sales Bins] on the Columns shelf
6. On the Marks card, change the mark type from Automatic to Bar in the dropdown menu
7. Add a reference line to the Sales Bin x-axis as normal. For detailed directions, see Reference Lines, Bands, Distributions, and Boxes

#### Option 2: Use a calculated field as a dual axis to mimic a reference line

1. Select Analysis > Create Calculated Field
2. In the Calculated Field dialog box that opens, do the following, and then click OK:
• Name the calculated field. In this example, the calculated field is named "Mock Reference Line"
• In the formula field, create a calculation similar to the following:
• `IF [Sub-Category]= "Chairs & Chairmats" OR [Sub-Category]= "Rubber Bands" THEN 1 END`
3. Drag [Mock Reference Line] to the Rows shelf.
4. On the SUM(Mock... Marks card, do the following:
• Change the mark type to Bar in the dropdown.
• Click Size and adjust the width of the bars with the slider.
5. Right-click the [Mock Reference Line] y-axis in the view and select Edit Axis...
6. In the Edit Axis dialog, do the following and close the dialog:
• For Range, select Fixed
• Set the range from 0 to 1
7. Right-click [Mock Reference Line] on the Rows shelf and check Dual Axis.
8. Right-click [Mock Reference Line] on the Rows shelf and uncheck Show Header.

### Cause

The ability to add a reference line to a discrete field is not currently available in Tableau Desktop.

### Additional Information

See the attached example workbook for a variation of Option 1 using dates.
Did this article resolve the issue?