MIP Logo

Compare current year sales vs previous year sales using year parameter

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

Today I will show you how to create the chart which allows comparing Sales of the current year vs the previous year, where you can change the current year using the parameter.

1. Create a Year parameter.

2. Create a calculated field [Current period] where DATEPART(‘year’, [Order Date]) = [Year parameter]

3. Create a calculated field [Same period last year], where YEAR([Order Date])= [Year parameter]-1

4. Create a calculated field [Last year sales ], where  if [Same period last year] then [Sales] else 0 end

5. Create a calculated field [This year Sales], where if [Current period] then [Sales] else 0 end

6. Create a calculated field [Difference btw years], where (SUM([this year sales])-SUM([Last year Sales]))/SUM([Last year Sales])

Bring [Same period last year], [Last year sales ], [Difference btw years] to columns; bring Segment to rows, show Year  parameter

You should end up with something like below chart.

The  downfall of this chart is that it’s too wide and maybe won’t look good on your dashboard. Also it’s not very easy to see the difference in numbers between the years. To make it a bit more compact we can use a dual axis for the [last year] pill and change the chart type in the Mark card for the last year sales to Gantt Bar.

Now the chart is easily readable and you have  the opportunity to dynamically change the year for comparison.

Share this post