Create Year Over Year Line Chart in Tableau

While analyzing sales performance, we wanted to compare our company’s sales performance over the past four years. We tried to visualize this data using a bar chart, but only knowing the yearly totals wasn’t enough to understand the monthly sales changes.

For this data visualization, I created a Year-over-Year (YoY) line chart in Tableau. Using this chart, we were able to display the yearly sales for the past year in a single view. With this, it is easy to see which months are improving, where sales are dipping, and how seasonal patterns repeat over time.

In this Tableau tutorial, I will explain about the year-over-year line chart in Tableau, and how to create one to compare the data over the years. In addition to this, I will also show how we can add a growth percentage for sales comparison in this chart.

Tableau Year-Over-Year Line Chart

In Tableau, a Year-Over-Year line chart is used to visualize the data where we need to compare the same measure, like Sales, Profit, or Revenue, across multiple years on a month-by-month basis.

Using this Year-Over-Year growth line chart, we can see each year’s trend on the same timeline and analyze the data for growth, decline, or seasonal patterns.

Create a Year-Over-Year Line Chart in Tableau

In this line chart, we will compare the Sales over the four years for each month. For this chart, we will use the Tableau Superstore dataset.

Connect Tableau to the data source and follow the steps below to create a year-over-year line chart in Tableau.

  1. To include the years, add the Order date to the Columns. By default, it will be in the year format. Click on the Order date and select the Month option.
Create a Tableau Year over Year Line Chart

With this, we can compare the monthly data over the years.

  1. Add the comparison measure, such as Sales or Profit, to the Rows. In this example, we will compare the monthly sales across years.
Year over year chart in Tableau
  1. Now, drag the Order Date to the Filters section. After this, in the Filter Field window, select Relative Date and click Next.
Tableau Year over year line chart
  1. In the Relative dates select Years -> Last 4 years and click OK.
Relative dates in Tableau Year over Year Chart
  1. To show all years in separate lines, add the Order date to the Color card in the Marks section.
Tableau Year over year growth line chart
  1. To add data points for the months on the year lines, click on the Color card and select Effects -> Markers -> dot lines (middle).
Year by year chart in Tableau

Now, on each data point on the lines, we can view the monthly sales for the specific year.

Year Over year line Chart in Tableau

This way, we can create a year-over-year line chart in Tableau, through which we can compare the measures over the year timelines.

Show Growth Percentage in Tableau Year-Over-Year Chart

To further customize the Year-Over-Year chart, we can also add a growth percentage to the sales comparison between years.

To compare the growth percentage, we will use the chart created in the previous steps and add the growth percentage to it.

  1. First, we need to create a calculated field that will calculate the growth or decline percentage of the sales over the years. For this, go to the Data tab -> Click dropdown -> Create Calculated Field.
Growth Percentage in tableau Year over year chart
  1. Enter the formula below in the calculated field and click OK.
(SUM([Sales]) - LOOKUP(SUM([Sales]), -1))
    / LOOKUP(SUM([Sales]), -1)
  1. Add the calculated field to the tooltip in the Marks section. With this, the data points will display the growth % in numbers such as 0.24 (24%).
Growth Line Year over year chart in tableau
  1. To format the percentage growth, click on the calculated field in the tooltip and select Format.
Add tooltip in tableau Year over year growth chart
  1. In the format select Pane -> Numbers -> Percentage -> set decimals as zero.
Tableau Year over year growth line chart in percentage

With this, we can now see the moth’s data points displaying the growth for a specific year and month in percentage.

Growth Percentage for year over year chart in tableau

This way, we can show the growth percentage in a Tableau year-over-year chart to show the percentage of growth or decline in sales.

Conclusion

In this Tableau tutorial, we have learned how to create a Year-over-Year (YoY) line chart in Tableau to compare monthly sales across different years.

In the above steps, we created the year-over-year chart to identify growth trends, patterns, and dips in performance. We also learned how to enhance the chart by adding a growth percentage calculation, which shows the exact increase or decrease in sales compared to the previous year.

You may also like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.