Recnac

# Tableau Playbook - Line Chart

• Sep 4, 2019
• 2,668 Views
• Sep 4, 2019
• 2,668 Views
Data
Tableau

## Introduction

Tableau is the most popular interactive data visualization tool, nowadays. It provides a wide variety of charts to explore your data easily and effectively. This series of guides - Tableau Playbook - will introduce all kinds of common charts in Tableau. And this guide will focus on the Line Chart.

In this guide (Part 1), we will focus on the concept and basic process of the line chart:

1. We will start with an example chart, and introduce the concept and characteristics of it.
1. By analyzing a real-life dataset: Rossmann Store Sales, we will learn to build a basic line chart step by step. Meanwhile, we will draw some conclusions from Tableau visualization.
2. As the basic common chart, we will talk about the variations of it.

## Getting Started

### Example

Here is a line chart example from Storytelling with Data. The following example uses a line to indicate the market size trend over time, and makes a forecast for 2019 based on the historical data.

### Concept and Characteristics

A line chart shows information as a series of data points connected by straight line segments. Line charts provide a simple way to visualize a sequence of values and are often used to show trends over time or even forecast future values. They can also apply to non-time series data, but they should only be used for ordinal data instead of categorical data.

Specifically in Tableau, we need one date type and at least one measure. Then it can indicate data trends over time intervals, such as weeks, months, fiscal years, and so on.

Line charts are good at showing the rise and fall in our data, and can even can show small variations. They pay special attention to the differences or trends. They also have high scalability, which means we can apply the level of detail expressions in this kind of charts.

On the other hand, line charts limit the number of dimensions. Moreover, it is hard to read when lots of lines are over-plotting each other.

### Date Part vs. Date Value

Let's take a moment to talk about the time-related concept in Tableau: date part and date value.

Here is a good explanation from Data School:

Dates in Tableau will behave differently depending on whether they are a datepart (blue) or a datevalue (green). This affects how the axes display/behave and also how visualisations such as line charts will display. The difference essentially boils down to dateparts behaving like a dimension as opposed to a measure which is how datevalues behave. This means that dateparts behave like discrete categories on the view whereas datevalues are more like continuous numeric values.

I made a table to compare the differences between Date Part and Date Value in various aspects:

AspectDate PartDate Value
Concepta part of date like day, month or yeara truncated date
Data Rolediscrete categoriescontinuous numeric values
Data Typeintegerdate
Color in Tableaubluegreen
ExampleDay=10, Month=5, Year=2019Day=5/10/2019, Month=5/1/2019, Year=1/1/2019

This diagram shows how to use this in Tableau:

## Dataset

In this guide, we use the Rossmann Store Sales dataset from this Kaggle Competition. Thanks to Rossmann and Kaggle for this dataset.

This dataset contains three-year sales data for 856 stores in Rossmann. Store sales are influenced by many factors, including promotions, competition, school and state holidays, seasonality, and locality.

I have done data wrangling and feature engineering for this dataset. You can download my version from Github for a better exploratory data analysis.

In this guide, we will analyze the Sales trend over time by Assortment or Promo.

## Basic Process

The line chart is one of the simplest chart types to create, but is also among the most powerful. Let's draw a basic line chart, step by step:

1. Click on Show Me and see the request for the line chart.

For lines (discrete), 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 (discrete)" in Show Me. Tableau will generate a raw discrete line chart automatically.

1. The "Sales" measure aggregated as `SUM` by default. But `SUM` is inappropriate here because the amounts of stores are different in each "Assortment". `AVG` is not suitable in this situation, either. There are two reasons. One is that some stores are closed on certain dates. The other reason is incomplete records. Therefore, `MEDIAN` is a better choice here: right-click "SUM(Sales)" and choose Measure -> Median.

1. In this example, we are going to display the weekly trend. According to the previous explanation, we need to change "YEAR(Date)" to WeekDay from discrete Date Parts.
1. Since there are not too many data points, we can add well-formatted labels to them.
1. Hold down the Control key (Command key in mac) which means make a copy and drag "MEDIAN(Sales)" into Marks - Label.
2. Right-click on "MEDIAN(Sales)" and click Format...
3. Expand Numbers in Default Option. Click Currency (Standard) and change to English (United States) if you haven't.
4. Then click Currency (Custom) and set Decimal places as 0.

1. In the last step, let's polish this chart:
1. Right-click on "Assortment" and choose Edit Aliases... Edit the members into "basic", "extra", "extended" which is more meaningful.
2. Edit the Title to "Weekly Sales Trends by Assortment".
3. Right-click on "Date" and choose Hide Field Labels for Columns.
4. Switch to Entire View.

A basic line chart is completed.

Analysis:

From this basic line chart, we can immediately see that the weekly Sales trends are similar for these three Assortments, except that Sunday sales of extended type are very low. Maybe store managers should consider closing on Sunday. Also, we find out the stores of extra type are the strongest performers.

## Variations

Line Charts are often used to show trends or continuous changes in the data over a period of time. By enhancing visualizations, there are some line chart variations applied to different scenarios:

• Use Dual Axis Line Chart when you need to combine two line charts.
• Choose Area Chart when you also need to pay attention to the magnitude or part-to-whole relation.
• When you only concern the general shape of the variation and make a comparison in some charts, Sparklines is the best practice.
• When you want to emphasize the magnitude of the change, Step Lines is a good choice. When you want to emphasize the duration of a value before it changes, you may consider Jump Lines. Here is a Dashboard of these line charts for comparison:

## Conclusion

In this guide, we have learned about one of the most common charts in Tableau - the Line Chart.

First, we started with an example of the line chart. Then we learned the concepts and characteristics of it. Next, we learned the basic process to build a line chart. In the end, we talked about other variations of the line chart.

In the second part, we will practice three typical line charts with a variety of advanced features.

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 [email protected].