Excel 2010
Creating PivotTables
Introduction
PivotTable reports (or PivotTables) make the data in your worksheets much more manageable by summarizing the data and allowing you to manipulate it in different ways. PivotTables can be an indispensable tool when used with large, complex spreadsheets, but they can be used with smaller spreadsheets as well.
In this lesson, you will learn the basics of creating and manipulating PivotTables.
PivotTables
When you have a lot of data, it can sometimes be difficult to analyze all of it. A PivotTable summarizes the data, making it easier to manage. Best of all, you can quickly and easily change the PivotTable to see the data in a different way, making this an extremely powerful tool.
Using PivotTables to answer questions
The example below contains sales statistics for a fictional company. There is a row for each order, and it includes the order amount, the name of the salesperson who made the sale, the month, the sales region, and the customer's account number.
Suppose we wanted to answer the question, "What is the amount sold by each salesperson?" This could be time consuming, as each salesperson appears on multiple rows, and we would need to add up all of the order amounts for each salesperson. Of course, we could use the Subtotal feature to add them, but we would still have a lot of data to sift through.
Luckily, a PivotTable can instantly do all of the math for us and summarize the data in a way that's not only easy to read but also easy to manipulate. When we're done, the PivotTable will look something like this:
As you can see, the PivotTable is much easier to read. It only takes a few steps to create one, and once you create it you'll be able to take advantage of the PivotTable's powerful features.
To create a PivotTable:
- Select the table or cells (including column headers) containing the data you want to use.
- From the Insert tab, click the PivotTable command.
The PivotTable command
- The Create PivotTable dialog box will appear. Make sure the settings are correct, then click OK.
The Create PivotTable dialog box
- A blank PivotTable will appear on the left, and the Field List will appear on the right.
The Blank PivotTable and Field List
To add fields to the PivotTable:
Now, you'll need to decide which fields to add to the PivotTable. Each field is simply a column header from the source data. It may be helpful to recall the question you are trying to answer. In this example, we want to know the total amount sold by each salesperson, so we'll just need the Order Amount and Salesperson fields.
- In the Field List, place a checkmark next to each field you want to add.
- The selected fields will be added to one of the four Areas below the Field List. In this example, the Salesperson field is added to the Row Labels area, and the Order Amount is added to the Values area. If a field is not in the desired area, you can drag it to a different one.
- The PivotTable now shows the amount sold by each salesperson.
Adding fields to the PivotTable
Just like with normal spreadsheet data, you can sort the data in a PivotTable using the Sort & Filter command in the Home tab. You can also apply any type of formatting you want. For example, you may want to change the Number Format to Currency. However, be aware that some types of formatting may disappear when you modify the PivotTable.
If you change any of the data in your source worksheet, the PivotTable will not update automatically. To manually update it, select the PivotTable and then go to OptionsRefresh.
Pivoting data
One of the best things about PivotTables is that they let you "pivot" the data in order to look at it in a different way. This allows you to answer multiple questions and even experiment with the data to learn new things about it.
In our example, we used the PivotTable to answer the question, "What is the total amount sold by each salesperson?" But now we'd like to answer a new question, such as "What is the total amount sold in each month?" We can do this by simply changing the Row Labels.
To change the Row Labels:
- Drag any existing fields out of the Row Labels area, and they will disappear.
Dragging a field out of Row Labels
- Drag a new field from the Field List into the Row Labels area. In this example, we're using the Month field.
Dragging a new field into Row Labels
- The PivotTable will adjust to show the new data. In this example, it now shows us the total Order Amount for each month.
The updated PivotTable
To add Column Labels:
So far, our PivotTable has only shown one column of data at a time. In order to show multiple columns, we'll need to add Column Labels.
- Drag a field from the Field List into the Column Labels area. In this example, we're using the Region field.
Adding a field to Column Labels
- The PivotTable will now have multiple columns. In this example, there is a column for each region.
The updated PivotTable
Report filters
Sometimes you may want focus on just a portion of the data and filter out everything else. In our example, we're going to focus on certain salespeople to see how they affect the total sales.
To add a report filter:
- Drag a field from the Field List into the Report Filter area. In this example, we're using the Salesperson field.
Adding a Report Filter
- The report filter appears above the PivotTable. Click the drop-down arrow on the right side of the filter to view the list of items.
- Select the item you wish to view. If you want to select more than one item, place a check mark next to Select Multiple Items, then click OK. In the example below, we are selecting five salespeople.
Using a Report Filter
- Click OK. The PivotTable will adjust to reflect the changes.
The updated PivotTable
Slicers
Slicers were introduced in Excel 2010 to make filtering data easier and more interactive. They're basically just report filters, but they're more interactive and faster to use, as they let you quickly select items and instantly see the result. If you filter your PivotTables a lot, you might want to use slicers instead of report filters.
To add a slicer:
- Select any cell in your PivotTable. The Options tab will appear on the Ribbon.
- From the Options tab, click the Insert Slicer command. A dialog box will appear.
The Insert Slicer command
- Select the desired field. In this example, we'll select Salesperson. Then click OK.
Selecting a field
- The slicer will appear next to the PivotTable. Each item selected will be highlighted in blue. In the example below, the slicer contains a list of all of the different salespeople, and four of them are currently selected.
A slicer with four selected items
Using the slicer:
Just like with report filters, only the selected items are used in the PivotTable. When you select or deselect items, the PivotTable will instantly reflect the changes. Try selecting different items to see how they affect the PivotTable.
- To select a single item, just click on it.
- To select multiple items, hold down the Control (Ctrl) key on your keyboard, then click on each item you want.
- You can also select multiple items by clicking and dragging the mouse. This is useful if the desired items are adjacent to one another, or if you want to select all of the items.
- To deselect an item, hold down the Control (Ctrl) key on your keyboard, then click on the item.
PivotCharts
PivotCharts are like regular charts, except they display data from a PivotTable. As with a regular chart, you'll be able to select a chart type, layout, and style to best represent the data. In this example, we'll use a PivotChart so we can visualize the trends in each sales region.
To create a PivotChart:
- Select any cell in your PivotTable. The Options tab will appear on the Ribbon.
- From the Options tab, click the PivotChart command.
The PivotChart command
- From the dialog box, select the desired chart type (3-D Clustered Column, for example), then click OK.
Selecting a chart type
- The PivotChart will appear in the worksheet. If you want, you can move it by clicking and dragging.
A PivotChart
If you make any changes to the PivotTable, the PivotChart will adjust automatically.
Challenge!
- Open an existing Excel workbook. If you want, you can use this example.
- Create a PivotTable using the data in the workbook.
- Experiment with different Row Labels and Column Labels.
- Filter the report with a slicer.
- Create a PivotChart.
- If you are using the example, use the PivotTable to answer the question, "Which salesperson sold the lowest amount in January?" Hint: First decide which fields you need in order to answer the question.