Working with Pivot Tables in Excel
In the information era, there are numerous ways to deal with your data; nonetheless, pivot tables are one of the most straightforward and effective ways to evaluate your data. In this article, we'll show you how to create pivot tables in Excel and how to use them for data analysis.
What are pivot tables?
Pivot tables in Excel offer several benefits that enable you to summarize and analyze large amounts of data to help quickly identify trends and patterns. They are a popular user-friendly tool enabling technical/non-technical people alike to dive deeper into their data.
At the most basic level, pivot tables enable you to create a data matrix in a row and column formats. You can apply filtering, sorting, aggregation, and summarization of your data in various ways.
Below is an example of a pivot table in action.
When working with pivot tables, there are four key components that you'll work with:
- Filters
- Columns
- Rows
- Values
Real World Example
This tutorial will use a dataset about global Bicycle sales from 2011 to 2016. This dataset's demographic information about customers and products is ordered with profit, cost, and revenue columns. You'll create a pivot table from this dataset, enabling you to analyze the data within.
The data is available here for you to follow along.
Reviewing the data
Let's start by reviewing a sample of the data for this tutorial. We have a table that contains 11 columns, including date, text, and numerical field types. From this subset of data, we see many ways we can work with this data to carry out our analysis and find some valuable insights.
Creating your first pivot table
To create your first pivot table, select the table from which you want to create your data, navigate to the Insert tab, and select Pivot Table from the options below.
Our new sheet shows the shell of our Pivot Table that has automatically been created for you. On the left-hand side of the screen, you can see an outline showing where the pivot table will appear once it’s been built. On the right-hand side, you’ll see the PivotTable fields pane that will appear where you’ll do the majority of your work with.
When your data is already in a table within Excel, Pivot Table will automatically include everything inside. However, it’s important to note that if your data is not inside a table element, you can manually select the data you want to include by highlighting the data to include and creating a pivot table the same way as before.
Adding your data
We will assume that each row is associated with an individual customer; therefore, there are no repeat orders. This is a highly simplified view of the dataset, but as there was no unique customer identifier, it’ll be easier for this tutorial to assume a single customer.
First, we’ll start by bringing a category field into the rows section. We will use Country for our category; we need to find it from the list of fields in the Pivot Table editor and then drag it into the Rows section. Next, we’ll need to look at the value we would like to evaluate - in this case, we want to count customers, but since we do not have an ID field, we can use the Customer_Age field, which we can drag into the Values section. By default, the aggregation is SUM, but we must update this to COUNT. We can fix this by right-clicking on the Customer_Age in the Values section, selecting Field Settings, changing Summarize from Sum to Count, and clicking OK.
Great job! We can now see a count of customers by the Country they ordered from. This is good to see, but let’s organize it by Country with the most customers. To do this, you’ll need to right-click on a value in the Count of Customer_Age column, select Sort, and then Sort Largest to Smallest. We can see that the United States had the most customers, with 39,206.
Taking it a step further
Now we’re familiar with how to set up a basic pivot table, let’s take this a step further and look at adding filters and columns and refreshing pivot tables. Let’s remove the rows and values we added in the previous step by right-clicking on them and selecting the Remove field. We now have a completely blank slate to work with.
For this pivot table, the question we will try to answer is, “In 2015, which quarter generated the most revenue, and what product/sub-category did it belong to?”
Let’s start by adding the rows we would like to analyze this data by; in our case, it will be Product_Category and Sub_Category. Next, for our columns, we want to see a breakdown of Quarters. But wait, we don’t have a Quarters column… that’s not a problem; Excel has automatically detected a date from our data, so when you drag Date into columns, you’ll see two new fields appear: Years and Quarters. Since we don’t need to view the data at an individual date level, we can remove this field from our Columns section.
Since we want to filter to 2015 for our question, we can move the Years field into the Filter section. Your pivot table should now look something like this:
Years and selecting 2015. This is now how our pivot table appears. Currently, our data points are at a singular level so the unit price and unit cost are associated with a single item. We’d like to correctly summarize the information and therefore need to move from our pivot table and back into our data table.
In the data tab, we will need to create a new calculated column to work out the revenue per row. For our calculation we need to multiply Order Quantity by Unit Price.
To add a new column to our data, navigate back to the data sheet, and next to our Unit Price column in row L2, we’ll add our new calculation; our formula will be:
[@[Order_Quantity]]*[@[Unit_Price]]
Now we have a new column that we can utilize in our pivot table. Navigate back to the sheet where your pivot table is, and we can see that the field doesn’t appear currently. To refresh our pivot table, right-click on any field and select Refresh.
Our new column has been added, and we can drag this into the Values section.
It looks messy, so let’s clean it up by removing all the grand totals, which you can do by going to the Design tab. Now open the Grand Totals dropdown and select Off for Rows and Columns. Next, let’s update the figures to show in currency. Highlight the values in the table, and on the home tab, update the values to Currency.
Go Further!
This tutorial was a good introduction to Pivot Tables using Excel; if you could follow along easily, well done! If you got stuck along the way, you can find the solution file here.
Try experimenting with a more complex dataset, applying different attributes, playing with them, and seeing if you can make some sense of the data.

Comments
Post a Comment