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 and 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.
Using a PivotTable 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, name of the salesperson who made the sale, month, sales region, and customer account number.
Let's say we wanted to answer the question What is the amount sold by each salesperson? This could be time consuming because each salesperson appears on multiple rows, and we would need to add 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 its 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 Create PivotTable dialog box will appear. Make sure the settings are correct, then click OK.
- A blank PivotTable will appear on the left, and the Field List will appear on the right.
To add fields to the PivotTable:
- In the Field List, place a check mark 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.
Note:- Just like with normal spreadsheet data, you can sort the data in a PivotTable using the Sort & Filter command on 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 a PivotTable is that it lets 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? Now we'd like to answer a new question, What is the total amount sold in each month? We can do this by changing the row labels.
To change row labels:
- Drag any existing fields out of the Row Labels area, and they will disappear.
- Drag a new field from the PivotTable Field List into the Row Labels area. In this example, we'll use the Month field.
- The PivotTable will adjust to show the new data. In this example, it now shows us the total Order Amount for each month.
To add column labels:
So far, our PivotTable has only shown one column of data at a time. To show multiple columns, we'll need to add column labels.
- Drag a field from the PivotTable Field List into the Column Labels area. In this example, we'll use the Region field.
- The PivotTable will now have multiple columns. In this example, there is a column for each region.
Using report filters
Sometimes you may want focus on a portion of the data and filter out everything else. In our example, we'll 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'll use the Salesperson field.
- 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 want 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 four salespeople.
- Click OK. The PivotTable will adjust to reflect the changes.
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 because 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.
- Select the desired field. In this example, we'll select Salesperson. Then click OK.
- 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 the different salespeople, and four of them are currently selected.
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, click it.
- To select multiple items, hold down the Control (Ctrl) key on your keyboard, then click 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 the item.
Using a PivotChart
A PivotChart is like a regular chart, except it displays 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.
- From the dialog box, select the desired chart type (3-D Clustered Column, for example), then click OK.
- The PivotChart will appear in the worksheet. If you want, you can move it by clicking and dragging.
If you make any changes to the PivotTable, the PivotChart will adjust automatically.
Challenge!
- Open an existing Excel 2010 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.