Pivot Table Excel: Getting the Difference Between Two Rows - Original Table Value
Pivot tables in Excel are a powerful tool for summarizing, analyzing, and presenting data in a meaningful way. One common use case is to compare the values of two rows in the original table and calculate the difference. This article will guide you through the process of getting the difference between two rows in an Excel pivot table, using the original table values.
Creating a Pivot Table in Excel
Before diving into the specifics of calculating the difference between two rows, let's first create a pivot table using the sample data provided:
Period Retailer Area Section People Type Metric1: Quantity Sold Q1 Dude area1 $11 Q1 Dude area2 $12 Q1 Dude area3 $13 Q1 Dude area4 $14 Q1 Dude area5 $15 Q1 Dude area6 $16 Q2 Dude area1 $10 Q2 Dude area2 $20 Q2 Dude area3 $30 Q2 Dude area4 $40 Q2 Dude area5 $50 Q2 Dude area6 $60
To create a pivot table, follow these steps:
- Copy and paste the sample data into an Excel worksheet.
- Click anywhere within the data range.
- Go to the Insert tab and click on PivotTable.
- In the Create PivotTable dialog box, ensure the correct data range is selected and choose where you want the PivotTable to be placed.
- Click OK.
Calculating the Difference Between Two Rows
To calculate the difference between two rows in the pivot table, follow these steps:
- Add the required fields to the pivot table (in this example, we will use Period, Retailer, and Metric1: Quantity Sold).
- Add a calculated field to get the difference between the two rows. To do this, go to the PivotTable Analyze tab, click on Fields, Items, & Sets, and then click on Calculated Field.
- In the Name box, enter a name for the calculated field (e.g., Difference).
- In the Formula box, enter the following formula:
=Sum(Metric1: Quantity Sold) - Prev(Sum(Metric1: Quantity Sold)) - Click Add and then click OK.
The Difference column will now show the difference between the current row and the previous row for the Metric1: Quantity Sold field.
Formatting the Pivot Table
To make the pivot table easier to read, you can format the values and headings. For example, you can change the number format for the Difference column to display as a percentage or currency.
In this article, we have covered how to create a pivot table in Excel, calculate the difference between two rows using the original table values, and format the pivot table for better readability. These techniques can be applied to various types of data and use cases, making pivot tables an essential tool for data analysis and presentation.