Excel2007 Pivot Tables

18
7/29/2019 Excel2007 Pivot Tables http://slidepdf.com/reader/full/excel2007-pivot-tables 1/18  Clayton State University Center for Instructional Development  Helen L. Brackett Updated: 7/6/2010 Excel 2007: Working with Pivot Tables Another way to work with lists of data is to create a pivot table. Pivot tables take a large amount of information and give you useful answers. Just a refresher about lists: Columns have headings at the top and each row contains the same kind of data. Excel calls this a list. Lists are made up of fields (the columns). Fields combine into records (the rows) to make the list. Some important things about lists: The column headers, also called the field names, must be formatted differently from the rest of the records. This can be as simple as using all caps, or adding bold or italics. This allows Excel to recognize the field names and treat them differently from the records. There should be no blank rows in the list. There may be blank cells where you don’t know the data (example: a person’s age), but don’t insert blank rows just to make it look good.  Each field in the record should be consistent. Age would always go in the age column, address in the address column, etc. Data should be consistent. Decide ahead of time on abbreviations. If you use Georgia, GA and Ga., it will be harder to filter the data. Be careful when you are entering the records. Leading and trailing spaces, such as a word followed by a space, are hard to find and will cause sorting to change. More about pivot tables There are three main sections in a pivot table: row, column, and data. If you are old enough to remember when incomes taxes were done with tax books, picture the old tax books where you had the income on the side, the number of dependents across the top and the amount of tax owed where they met. If this were a pivot table, the income would be in the row, the number of dependents would be in the column, and the amount of tax owed would be in the data section. In a pivot table you will always use the data section. You may choose to use a row, column, or  both. You do not have to use all of the fields in a list in the pivot table, and you may use a field more than once. How to get the answers you want Suppose you have a list like this:

Transcript of Excel2007 Pivot Tables

Page 1: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 1/18

 Clayton State University

Center for Instructional Development 

 Helen L. Brackett Updated: 7/6/2010

Excel 2007: Working with Pivot Tables

Another way to work with lists of data is to create a pivot table. Pivot tables take a large amountof information and give you useful answers.

Just a refresher about lists:Columns have headings at the top and each row contains the same kind of data. Excel calls this alist. Lists are made up of fields (the columns). Fields combine into records (the rows) to makethe list.

Some important things about lists:

The column headers, also called the field names, must be formatted differently from the rest of the records. This can be as simple as using all caps, or adding bold or italics. This allows Excelto recognize the field names and treat them differently from the records.

There should be no blank rows in the list. There may be blank cells where you don’t know thedata (example: a person’s age), but don’t insert blank rows just to make it look good.  

Each field in the record should be consistent. Age would always go in the age column, addressin the address column, etc.

Data should be consistent. Decide ahead of time on abbreviations. If you use Georgia, GA andGa., it will be harder to filter the data.

Be careful when you are entering the records. Leading and trailing spaces, such as a wordfollowed by a space, are hard to find and will cause sorting to change.

More about pivot tables

There are three main sections in a pivot table: row, column, and data. If you are old enough toremember when incomes taxes were done with tax books, picture the old tax books where youhad the income on the side, the number of dependents across the top and the amount of tax owedwhere they met. If this were a pivot table, the income would be in the row, the number of dependents would be in the column, and the amount of tax owed would be in the data section.

In a pivot table you will always use the data section. You may choose to use a row, column, or  both. You do not have to use all of the fields in a list in the pivot table, and you may use a fieldmore than once.

How to get the answers you want

Suppose you have a list like this:

Page 2: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 2/18

 Clayton State University 2

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The fields are Name, Rank, Department, Sex and Salary. You would like to know the averagesalary for women. You could answer this with a total row in a table or by using data subtotals, but this question is also an ideal candidate for a pivot table.

First, think about what fields are involved. In this case, we will need the sex field since itcontains the M/F info and the salary field since it contains the salary info.

The mathematical function, whether it is average, count, sum, etc., must go in the data section.That leaves the sex field to go either in the row or column section. When you are going to useonly one column or one row, most people select row. So let’s plan to put sex in the row section

and salary in the data section.

Creating the Pivot Table

Download a file to work with here. 

1. Begin by clicking someplace in the list.

2. Click on Insert on the menu. Select PivotTable at the far left side of the Insert ribbon in theTable group. Select Pivot Table from the drop down list.

3. Because you began by clicking inside the list, Excel should figure out the correct table or range in the Create PivotTable window. If the range is incorrect, click on the collapse dialog box icon and select the correct range. Click on the Expand dialog box icon to return to theCreate PivotTable window.

Page 3: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 3/18

 Clayton State University 3

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Choose the location for the pivot table – either a new worksheet or an existing worksheet. If you select an existing worksheet, click on the collapse dialog box and select a cell on anyworksheet. Click on the Expand dialog box icon to return to the Create PivotTable window.Click on OK.

4. The PivotTable grid should appear on the left side of your worksheet. A field list shouldappear on the right side of the same page.

The grid:

Page 4: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 4/18

 Clayton State University 4

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The field list:

 Note; If you click outside of the grid, the field list will disappear. Just click anywhere insidethe grid to make the field list reappear.

5. Select the box in front of Sex in the field list. M and F should appear in the row section of the grid. It also appears under Row Labels in the Field list.

6. Select the box in front of Salary in the field list. Total figures for the Salary appear in thegrid and Sum of Salary appears under Values in the field list.

An alternative is to click on the field in the field list and drag it either into the appropriate box at the bottom of the field list OR into the appropriate spot in the grid.

Page 5: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 5/18

 Clayton State University 5

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The Salary by Sex PivotTable grid and field list look like this:

At this point we have gleaned some useful information, such as the total salaries for men andfor women, but our original question was what was the average salary for women. So we’renot quite there yet.

7. Click on the arrow to the right of Sum of Salary in the Values box in the Field list.

8. Select Value Field Settings. Select Average.

Page 6: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 6/18

 Clayton State University 6 

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

8. Click on OK. The grid changes to:

 Note how the label has changed from Sum of Salary to Average of Salary. The numbersunderneath Total are averages, not Sums. Select them and format them for currency.

So the answer to our question about the average salary for women is: $37,694.20.

Page 7: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 7/18

 Clayton State University 7 

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Let’s do another one 

The question: How many men and women are in the Music department?

Think: what fields will we need to use?  Hint: remember we can use fields more than once. 

We’ll need to use the sex and department fields. 

1. Click inside the Excel list back on the original sheet.

2. Click on Insert on the menu. Select PivotTable at the far left side of the Insert ribbon in theTable group. Select Pivot Table from the drop down list.

3. Doublecheck that the selected table/range is correct. Select New Worksheet for the location.Click on OK.

4. Click on the Sex field in the field list; drag it into the Row Labels text box at the bottom of the field list.

5. Click on Department and drag it into the Column Labels text box at the bottom of the fieldlist.

6. Click on the Sex field in the field list; drag it into the Value text box at the bottom of thefield list.

So the PivotTable grid and field list look like this:

Page 8: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 8/18

 Clayton State University 8

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

From this we can answer: there are six women and seven men in the Music department.

Important note: We put the sex field in the rows and the department field in the columns,

 but what would happen if we reversed things and put department in the rows and sex in thecolumns? Your results would look like this:

Page 9: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 9/18

 Clayton State University 9

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Can you still answer the question “how many men and women in the Music department?

Yes, you can, so placement in rows or columns really doesn’t matter. 

 Now try this:

7. Drag Department from the Column Labels text box to the Row Labels text box right under 

Sex.

Page 10: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 10/18

 Clayton State University 10

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The field list now looks like this:

Page 11: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 11/18

 Clayton State University 11

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The PivotTable grid looks like this:

Can you still answer the question “how many men and women in the Music department?”There are still six women and seven men in the Music department. Your answers didn’t

change; only the grid layout did.

How about one more?

How many female, full professors are there in the music department?

Using the pivot table you just created, drag Rank into the Column Labels.

Page 12: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 12/18

 Clayton State University 12

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The field list and the grid should look like this:

Page 13: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 13/18

 Clayton State University 13

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

The answer is: there are four full professors in the Music department.

By now you should see why consistency in the records is so important: if one entry in afield is different from related entries (i.e,: Pt.time instead of Part-Time or Asociate instead of Associate) the PivotTable grid will contain an incorrect entry.

 Now try this:

We know that there are four full, female professors in the Music department, but we’d liketo filter out some of the other information so that we can see it easier.

Click on the drop down arrow to the right of department.

Page 14: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 14/18

 Clayton State University 14

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Click on the Select All icon. This DESELECTS all boxes. Then select ONLY the Music box. This filters out all but the Music department and makes our answer easier to see.

To remove the filter, click on the arrow to the right of Department. Click on Select All.

You can apply more than one filter. For example, you could filter out all departments exceptfor Music and all ranks except for Full.

Page 15: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 15/18

 Clayton State University 15

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Let’s try one more thing. Clear all filters so that your entire grid is visible again. (Hint: click on each arrow that has the filter symbol on it and Select All)

In the field list, drag Department from the Row labels to the Report Filter box.

This moves Department up to the top of the PivotTable grid.

Page 16: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 16/18

 Clayton State University 16 

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Click on the arrow to the right of Department (All) to apply a filter.

The only limit to the number of PivotTables you can create from list of data is the amount of RAM memory available in your computer. If you put each PivotTable on its own sheet, youcan name each sheet with a descriptive name.

Using the PivotTable Tools Options and Design.

The PivotTable Tools Options and Design tabs appear ONLY if your active cell is inside a pivot table. The Options and Design ribbons contain icons that repeat some of the functionsincluded in the Field List and also some icons that control how the pivot table looks.

Sorting your results

You can sort PivotTables just like any other Excel data. For example, in this example,women come before men because F comes before M.

\

However, you might want to sort descending by grand total meaning that the row for the 32men would come before the row for the 25 women. To do this click in either of the two

grand total cells, E5 or E6, then sort largest to smallest using the sort icon on the PivotTableTools ribbon or the sort icon on the Home ribbon. Your results should look like this:

Page 17: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 17/18

 Clayton State University 17 

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

 Note that even though you selected only cells E5:E6, the sort moved the entire row.

Removing a field from the pivot table

To remove a field from the pivot table, click on the arrow to the right of the field name in the bottom section of the field list and select remove field.

Page 18: Excel2007 Pivot Tables

7/29/2019 Excel2007 Pivot Tables

http://slidepdf.com/reader/full/excel2007-pivot-tables 18/18

 Clayton State University 18

Center for Instructional Development 

 Helen L. Brackett 

Updated: 7/6/2010

Updating pivot tables

If you add new data to the list that the pivot tables are based on, you’ll need to update the pivot tables to include that data. Click any place in the pivot table grid, then:

1. Click on Options under PivotTable tools at the top of the screen.

2. Click on the Refresh icon in the Data group. Your choices are Refresh and Refresh All.Refresh updates only the pivot table where your active cell is located. Refresh All refreshesall pivot tables in the worksheet.

If the Field List on the right side of the screen disappears, click inside a pivot table. Thefield list should reappear. If it does not, click inside a pivot table then click on Optionsunder the Pivot Table tools at the top of the screen. Click on the Field List icon in theShow/Hide group.