Excel 2010: Creating PivotTables

Lesson 20: Creating PivotTables

/en/excel2010/using-conditional-formatting/content/

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

When you have a lot of data, it can sometimes be difficult to analyze it all. 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 it an extremely powerful tool.

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.

Company Sales Statistics

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:

A finished PivotTable

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:

1. Select the table or cells—including column headers—containing the data you want to use.
2. From the Insert tab, click the PivotTable command.
The PivotTable command
3. The Create PivotTable dialog box will appear. Make sure the settings are correct, then click OK.
The Create PivotTable dialog box
4. 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:

You'll need to decide which fields to add to the PivotTable. Each field is 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 need the Order Amount and Salesperson fields.

1. In the Field List, place a check mark next to each field you want to add.
2. 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.
3. The PivotTable now shows the amount sold by each salesperson.

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:

1. Drag any existing fields out of the Row Labels area, and they will disappear.
Dragging a field out of Row Labels
2. Drag a new field from the PivotTable Field List into the Row Labels area. In this example, we'll use the Month field.
Dragging a new field into Row Labels
3. 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

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.

1. Drag a field from the PivotTable Field List into the Column Labels area. In this example, we'll use the Region field.
Adding a field to Column Labels
2. The PivotTable will now have multiple columns. In this example, there is a column for each region.
The updated PivotTable

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.

1. Drag a field from the Field List into the Report Filter area. In this example, we'll use the Salesperson field.
2. 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.
3. 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.
Using a Report Filter
4. 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 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.

1. Select any cell in your PivotTable. The Options tab will appear on the Ribbon.
2. From the Options tab, click the Insert Slicer command. A dialog box will appear.
The Insert Slicer command
3. Select the desired field. In this example, we'll select Salesperson. Then click OK.
Selecting a field
4. 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.
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, 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.
Ctrl-clicking to select multiple items

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:

1. Select any cell in your PivotTable. The Options tab will appear on the Ribbon.
2. From the Options tab, click the PivotChart command.
The PivotChart command
3. From the dialog box, select the desired chart type (3-D Clustered Column, for example), then click OK.
Selecting a chart type
4. 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!

1. Open an existing Excel 2010 workbook. If you want, you can use this example.
2. Create a PivotTable using the data in the workbook.
3. Experiment with different row labels and column labels.
4. Filter the report with a slicer.
5. Create a PivotChart.
6. 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.

/en/excel2010/using-whatif-analysis/content/