Using a reference line

A reference line is simply a line that gets drawn on a chart that represents another measure or point of reference. Reference lines can be useful in providing context to the related chart. For example, a line showing the median will visually show the difference of each mark in the chart relative to the median.

In this recipe, we will show some of the top movie genres from 2007-2011 based on worldwide gross amount and add reference lines to show the average overall and average per year:

Using a reference line

Getting ready

To follow this recipe, open B05527_06 – STARTER.twbx. Use the worksheet called Reference Line, and connect to the HollywoodsMostProfitableStories data source:

Getting ready

How to do it...

Here are the steps to create the bar graph with reference lines:

  1. From Dimensions, drag Year to Rows.
  2. From Dimensions, drag Genre to Rows to the right of the Year pill.
  3. From Measures, drag Worldwide Gross Amount to Columns.
  4. Hover over the Worldwide Gross Amount axis, and click on the sort icon once to sort the bars in descending order.
  5. On the side bar, click on the Analytics tab to activate it.
  6. Under Custom, drag Reference Line from the Analytics tab and drop it onto the Table placeholder:
    How to do it...
  7. Set the following for this reference line:
    • Scope as Entire Table
    • Under Line, setValue, set the aggregation to Average of the SUM(Worldwide Gross Amount)
    • Under Line Label, set it to Custom with Average <Value> as text; note you can use the > button to insert values
    • Under Formatting, set Line to a thick, dark red line
    • Under Formatting, set Fill Above: to None
    • Under Formatting, set Fill Below: to None:
    How to do it...
  8. Click OK when done.
  9. Under Custom, drag Reference Line again from the Analytics tab and this time drop it onto Pane.
  10. Set the following for this reference line:
    • Scope is Per Pane
    • Under Line Value, set the aggregation to Average of the SUM(Worldwide Gross Amount)
    • Under Line Label, set it to Value
    • Under Formatting, set Line to a thick gray line
    • Under Formatting, set Fill Above to None
    • Under Formatting, set Fill Below to a light yellow color
  11. Click OK when done.

How it works...

Reference lines can provide additional context to our visualizations, by adding a visual cue that identifies where a reference is relative to the values we are looking at.

In Tableau, adding a reference line is made easier with the Analytics pane. With a single drag from the Analytics pane, a reference line can be added to a view. Alternatively, the reference line can also be added by right-clicking on an existing axis and choosing Add Reference Line.

In the Edit Reference Line, Band, or Box window, additional settings can be applied, such as scope, fill, and a choice to add the confidence interval. From this window, the type of reference can also be chosen – line, band, distribution, or box plot:

How it works...

There's more...

When adding a reference line, it is important to remember that the field you want to use as a reference line must be in the view already. If it is not in the view, and if it is not a parameter, the value must be added first to the Details property in the Marks card before it can be used in the Reference line window.

Using parameters for reference lines also add interactivity to your views. This allows the consumers of your dashboards to try out different values and see the visualization change instantly.

See also

  • Please refer to the Adding a constant line recipe in this chapter
  • Please refer to the Adding a reference band recipe in this chapter
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.26.138