top of page

You are learning PivotTables in MS Excel

How to calculate year-over-year comparisons in a PivotTable?

There are two main methods to calculate year-over-year comparisons in a PivotTable:

Method 1: Calculated Items

1. Create a PivotTable: Ensure you have a PivotTable set up with your data, including a "Date" field (or a year extracted from the date).
2. Group by Year: Drag the "Date" field (or year field) to the "Columns" section of the PivotTable to group your data by year.
3. Show Values: Drag the value you want to compare (e.g., Sales) to the "Values" section. This will display the sum (or another aggregation) for each year.
4. Insert Calculated Item: Right-click on the heading for a specific year (e.g., 2023) and select "Insert Calculated Item" from the menu.
5. Create Formula: In the formula window, you'll see a base formula starting with =. Here, you can create a formula to compare the current year to the previous year.
- For example, to calculate the difference between 2023 and 2022 sales, enter a formula like: `= [2023] - [2022]`.
- Double-click on the year labels ([2023] and [2022]) to insert them into the formula.
6. Name the Item: Give your calculated item a clear name, such as "Change from 2022" or "YoY Change."
7. Repeat (Optional): You can repeat steps 4-6 to create calculated items for other year-over-year comparisons.

Method 2: Show Values As

1. Follow steps 1-3 from method 1 to set up your PivotTable with years and values.
2. Right-Click on Value: Right-click on the value field in the "Values" section (e.g., Sum of Sales).
3. Show Values As: Select "Show Values As" from the context menu.
4. Choose Difference From: In the "Show Values As" options, choose "% Difference From" or "Difference From" depending on whether you want percentage change or absolute difference.
5. Base Field: Select the "Date" field (or year field) as the "Base Field."
6. Base Item: Choose "Previous" as the "Base Item" to compare the current year to the prior year.

Both methods achieve the same result: displaying the year-over-year comparison alongside your data in the PivotTable. Choose the method that best suits your workflow and preference.

Additional Tips:

* You can format the calculated items or the "Difference From" values to display them as percentages or with specific number formatting.
* You can hide the original year value columns if you only need the year-over-year comparison displayed.
* PivotTables offer flexibility, so you can adapt these methods to compare different metrics or date ranges.

bottom of page