Creating a Line chart

Another frequently used chart type is the Line chart, which is primarily used to show trends over a period of time. This chart type helps us focus on the peaks and dips in the values over a period of time.

The line chart in Tableau uses the Line mark type.

Getting ready

To understand this chart type better, let's create a Line chart to show profit for all the months over the last 4 years.

How to do it…

  1. Let us create a new sheet and rename it to Line chart.
  2. Next, we will drag Order Date from the Dimensions pane and drop into the Columns shelf.
  3. Drag Profit from the Measures pane and drop it into the Rows shelf. Refer to the following image:
    How to do it…
  4. Next, we will click on the dropdown for the Blue pill in the Rows shelf, which says Year(Order Date), and select the Month option from the second list—not the first list, which is identical—showing Year, Quarter, Month, and so on. Refer to the following image:
    How to do it…
  5. Once we do this, we will get the view as shown in the following image:
    How to do it…

How it works…

In the recipe for Bar chart, we had Region in the Columns shelf and Sales in the Rows shelf. This is a similar situation where we have Dimension in the Columns shelf and Measure on the Rows shelf.

However, in the preceding recipe, the Dimension that is placed in the Columns shelf is not an ordinary dimension. It is a date field, and in addition to this when we get a measure in the Rows shelf, Tableau will create a line chart.

Further, when we get Order Date in the view, Tableau intelligently aggregates the dates at the highest level possible. For example, if the date field includes multiple years, the default level is year. However, if the date field contains data for just one year but includes multiple months, then the default level is month. In the preceding scenario, the highest level is Year.

We can drill down to the desired level of date by clicking on the plus button on the Date field. Refer to the following image:

How it works…

Further, a date can be discrete as well as continuous. In the preceding recipe, when clicked on the dropdown of Year(Order Date), we saw that there were two sections that showed the year, quarter, month, and so on. We selected the month from the second section, which was for a continuous month and thus got a continuous line chart. See the following image to understand the difference between a discrete line chart versus a continuous line chart.

How it works…

In the first chart in the preceding image, we have the years on the top and the months at the bottom. This view creates a small table for each year and hence the line is broken after each year. However, in the second chart, the month is combined with the year to show one data point (notice the x axis). These data points when connected via a line create a continuous line chart.

..................Content has been hidden....................

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