Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Tableau Playbook - Advanced Line Chart

Sep 4, 2019 • 10 Minute Read

Introduction

This is the second part of a two-part series on Tableau Playbook - Line Chart. In the first part, we delved into the concept and basic process of the line chart. Check it out in case you missed it.

In this guide (Part 2), we will focus on the advanced usages of the area chart. By analyzing a real-life dataset, Rossmann Store Sales, we will practice three of the typical line charts with advanced features step by step. Meanwhile, we will draw some conclusions from Tableau visualization.

Discrete Line Chart

If we want to illustrate the seasonal trends by years, we can consider a discrete line chart.

  1. First, we need to update the role of some data fields. We should multiselect "IsHoliday", "Promo", "Promo2", "SchoolHoliday", "StateHoliday" and "Store" and Convert to Dimension.

    discrete line chart 1

  2. For a complex chart, we build it manually.

    1. Since we want to display the monthly trends by years, we drag "Date" into Columns Shelf twice and change types to Year and Month from discrete Date Parts.
    2. Drag "Sales" into Rows Shelf.
    3. Aggregated by median which we have discussed before. Right-click "SUM(Sales)" and choose Measure -> Median.
    4. Drag "Promo" into Marks - Color.
  3. We intend to truncate the y-axis for a better view, although improper usage may lead to a misleading graph. But here we’ll mainly focus on the trend and comparison, so it is an appropriate usage according to this article from Quartz.

    1. Right click on the y-axis and click Edit Axis...
    2. Uncheck Include zero.

    discrete line chart 2

  4. Let's format the discrete date header for a better view:

    1. Right-click on the horizontal header and click Format...
    2. Expand Dates in Default Option from Header tab and choose Abbreviation.
  5. Put on the finishing touches:

    1. Right-click on "Promo" and choose Edit Aliases... Edit the members into "No" and "Yes" and drag to reorder.
    2. Rename color Legend to "Promotion".
    3. Edit the Title to "Monthly Sales Trends by Promotion".
    4. Right-click on "Date" and choose Hide Field Labels for Columns.
    5. Switch to Entire View.

    discrete line chart 3

Analysis:

This discrete line chart gives us a clearer idea of the monthly trends by years. We can see in every year, the sales increase rapidly since September, and peaked in December.

Continuous Line Chart

In order to show the overall trend, we can change the previous chart into a continuous line chart.

  1. Right-click on the sheet tab of the previous discrete line chart and click Duplicate.

  2. Change the line chart from discrete to continuous.

    1. Remove one date field from Columns Shelf.
    2. Change the other into Month from continuous Date Values.

    continuous line chart 1

  3. Format the continuous date axis for a better view. We can see the format options are totally different.

    1. Right-click on the x-axis and click Format...
    2. Expand Dates in Scale Option from the Axis tab and choose Custom. Then customize the format as mmm yyyy. For more date format information, please refer to the supported date format symbols table.
  4. Let's polish this chart:

    1. Change the title to "Sales Overall Trends by Promotion".
    2. Remove the date axis title "Month of Date" in Edit Axis...

Analysis:

Compared with the previous discrete line chart, we realize this continuous line chart connects the separate parts into a single line. It gives a more macro and complete time series analysis. From this overall trend, we can see the sales obey the yearly seasonal pattern.

Trend Lines and Forecast

In the last section, let me introduce two common techniques often used in line charts: trend lines and forecast.

  1. This time we generate a continuous line chart by Show Me:

    For lines (continuous), try 1 date, 0 or more Dimensions, 1 or more Measures.

    Hold down the Control key (Command key on Mac) while clicking to multiple select "Assortment", "Date" and "Sales", then choose "line (continuous)" in Show Me. Tableau will generate a raw continuous line chart automatically.

    line chart with trend lines and forecast 1

  2. We optimize it as we did before:

    1. Right-click "YEAR(Date)" on Columns Shelf and choose Month from continuous Date Values.
    2. Right-click "SUM(Sales)" on Rows Shelf and choose Measure -> Median.
    3. Truncate the y-axis to make the chart more visible: right click on y-axis and click **Edit Axis... **Then uncheck Include zero.
  3. With the forecast technique, Tableau visualizes estimated future values of the measure, in addition to actual historical values.

    line chart with trend lines and forecast 2

    1. Right-click on the view and check Forecast -> Show Forecast.
    2. Drag "Forecast indicator" out of the pane to remove.
    3. Try more advanced features in Forecast - Forecast Options... You can learn more about forecast options from this official document.
  4. Show trend lines in the visualization to highlight trends in your data:

    line chart with trend lines and forecast 3

    1. Right-click on the view and check Trend Lines -> Show Trend Lines.
    2. Open the pop-up menu again and click Trend Lines -> Edit Trend Lines....
    3. Check Show Confidence Bands in Options dialog. It shows upper and lower 95% confidence lines by default when you add trend lines.
    4. Try more advanced features in the Options dialog. You can learn more about trend lines options from this official document.
  5. Pursue better formatting:

    1. Right-click on the x-axis and click Format... Expand Dates in Scale Option from the Axis tab and choose Custom. Then customize the format as mmm yyyy.
    2. Edit the Title to "Sales Predictions by Assortment".
    3. Remove the date axis title "Month of Date" in Edit Axis...

Analysis:

Aided by the trend lines, this line chart shows that sales are steadily growing despite seasonal fluctuations, rather than emphasizing monthly spikes. We can see the sales of extra type has the highest growth rate.

With the help of the forecast, we can predict future sales roughly based on historical data. The shaded bands show the 95% prediction intervals, which means Tableau is 95% confident that the correct prediction exists within this range.

Conclusion

In this guide, we have learned the advanced usages of the line chart. First, we built the two typical line charts: discrete and continuous line chart. Moreover, We enhance the line chart with trend lines and forecast.

You can download this example workbook Line Chart and Variations from Tableau Public.

In conclusion, I have drawn a mind map to help you organize and review the knowledge in this guide.

I hope you enjoyed it. If you have any questions, you're welcome to contact me at recnac@foxmail.com.

More Information

If you want to dive deeper into the topic or learn more comprehensively, there are many professional Tableau Training Classes on Pluralsight, such as Tableau Desktop Playbook: Building Common Chart Types.

I made a complete list of my common Tableau charts serial guides, in case you are interested:

CategoriesGuides and Links
Bar ChartBar Chart, Stacked Bar Chart, Side-by-side Bar Chart, Histogram, Diverging Bar Chart
Text TableText Table, Highlight Table, Heat Map, Dot Plot
Line ChartLine Chart, Dual Axis Line Chart, Area Chart, Sparklines, Step Lines and Jump Lines
Standard ChartPie Chart
Derived ChartFunnel Chart, Waffle Chart
Composite ChartLollipop Chart, Dumbbell Chart, Pareto Chart, Donut Chart