You are on page 1of 8

Pivot Tables

Introduction
Excel allows you to create cross-tab (or cross-tabulation) analysis in what it calls a Pivot
Table.
Pivot tables can be one, two or three-dimensional. You can use multiple statistical analysis
and summary options tools. You can include data from multiple worksheets and you can
modify them dynamically.

Creating a Pivot Table


1. Open exceldata.xlsx, found in Canvas.
2. Click on the Accounts tab.
3. Click on cell A2.
4. On the Insert tab click on the [PivotTable] button.
5. The Create Pivot Table box opens:

6. Notice that the default area contains your entire data range. Accept the default area.
7. Place the Pivot Table on the Existing Worksheet in cell G4 and click [OK].
8. The Pivot Table builder opens.
9. Two PivotTable tabs (Analyze and Design) appear on the Ribbon (shown below).

10. The next step is to specify which data series you are using in your cross-tabulation by
moving the fields from the PivotTable Fields area to the areas below that for Filters,
Columns, Rows and Values.

A One-Dimensional Table
We have learned how to insert subtotals in Excel. You can also get subtotals by using one-
dimensional pivot tables.

11. Drag the [Employee] field list item into the Rows area and ‘drop‘ it.
12. Drag the [Amount] field list item into the Values area and ‘drop’ it.

You now have the total expenditures for each employee.


Since we used Amount, which is numeric, the SUM function is applied to the values.
If we had used a text field, the COUNT function would have been applied.

Now let’s resort the names in a different order and show the values as money.

13. Use the pull down on the Row Labels in the Pivot Table area and choose [Sort Z to A].
14. Highlight cells H5 through H12.
15. Click the dollar sign in the Number area of the Home tab.
A Two-Dimensional Table
By using a second dimension (i.e. a column field as well as a row field), you can get a more
detailed breakdown of the figures. Let’s find the expenditures for employees by category.

16. Add the [Category] field list button to the Columns area.

A Three-Dimensional Table
You can add a third dimension to a pivot table by having a drop-down list from which you select
the third variable. For our existing pivot table, this is not currently a viable option because all
other areas in our sheet refer to dates, and most every date is a different value.
Instead, you’ll create a new field for the Month. You can get this by separating just the month
information from the rest of the date.

17. In cell E1 type the heading Month and press [Enter]


18. In cell E2 type the formula ‘=text(a2,"mmm")’ and press [Ctrl-Enter].
19. Double click on the small black handle attached the cell to fill down the column.
20. Click on any cell within the pivot table to reactivate the PivotTable work area, which
‘hides’ while you are working in other data in the sheet.
21. In the Data area of the Analyze tab, choose [Change Data Source].
22. Change $D$61 to $E$61.
23. Click [OK].
24. Drag and drop the new [Month] field button into the Filters area.
25. Click on the list arrow in cell H2, select “March" then click on [OK].
26. Repeat step 25, clicking the box next to Select Multiple Values and then add “Feb” to
the filter.

Hiding and Showing Summary Values


If you don't want certain values displayed then you can omit data from the Pivot Table.

27. In the pivot table fields area, when you mouse over the Category column field, you’ll
see an arrow appear on the right side of the highlighted area.
28. Click on the arrow to open an expanded detail box.
29. In the bottom of this section, you’ll see an area where you can further filter the data.
Click on the Stationery check box to unselect it and then click [OK].
Adding New Data
To summarize other data values, you simply drop them into the Data area of the pivot table.

30. Drag the Employee field area into the Values area and ‘drop’ it.
31. The count is shown as currency, both in the Count columns for Travel and Food as well
as the Total column.
32. Highlight (each column separately), right click and go to Format Cells. Choose the
‘General’ option to remove the Currency format from those columns.

Altering Table Layout


You can also alter how the pivot table looks:

33. In the Values area, drag the Count of Employee box above the Sum of Amount.
34. In the Columns area, drag the Values box above the Category box.

Changing the Summary Statistics


35. In the Pivot Table design area, drag the Amount field to Values, so that the Sum of
Amount shows more than once.
36. In the Values area of the Pivot Table Fields window, click the arrow to the right of the
new Sum of Amount field that you just added. Go to Value Field Settings and click to
open the Value Field Settings window, shown below:

37. Change the setting to Average – the Custom name will change but will still say ‘2’.
38. Take out the 2 so the Custom Name is Average of Amount.
Note** notice that we added the same data to the pivot table twice – this can be a very
valuable feature in Excel for analyzing the same data in multiple ways.
Changing the Data Format
39. In the Values area of the Pivot Table Fields window, click the arrow to the right of the
Count of Employee field. Go to Value Field Settings and click to open the Value Field
Settings window.
40. Click on the [Number Format] button.
The Format Cells window appears.
41. Change the Category: to Number and set Decimal places: to 0.
42. Click [OK] to confirm this.
43. Click [OK] to close the Value Field Settings dialog box.

Multiple Row/Column/Page Fields


You can have more than one Row, Column or Page field in a pivot table.
If you had years as well as months, you could then select a specific month in a specific year.
To display the breakdown by month for the current pivot table, you have to move the Month
field.

44. Click in cell G4 when you see the black right facing arrow to highlight the whole pivot
table, then [Ctrl-C] to copy it.
45. Click in cell G18 and [Ctrl-V] to paste the pivot table.
46. In the new pivot table, use the pulldown next to Month (that says (Multiple Items) and
unselect February and March so that all items are included.
47. In the new pivot table, drag the Month field from the Filters box to the Rows area.
48. In the Rows area, drag Month above Employee.
Note that to show or hide particular data for a month, you can click the [-] (which then turns to
a [+]) or click the [+] to reshow the detail.

Grouping and Details


Earlier in this lecture we calculated a Month field, to view the monthly expenditure statistics.
You can actually group data within pivot tables, so it actually wasn’t really necessary to
calculate a new Month field. 
The data in the field dictates what grouping options are available.
Numbers can be grouped in equally-sized ranges, while dates/times can be summarized by
years, quarters, months, days, hours etc. You cannot group text values.

49. Copy columns A-D (NOT the month column we created earlier) and paste into cell A1 of
‘Sheet1’.
50. Click on cell C3 (or any single cell within the data you pasted).
51. Insert a pivot table using this data into the same worksheet in cell G2.
52. Drag Date to Rows, Amount to Values and Category to Columns.
53. Next, right click on any date value in the pivot table and choose Group. The Grouping
dialog box appears:

54. Change the Starting date: to 1/1/2001.


55. Under the heading By: select Months then click [OK].
56. Click on cell G2 to highlight the whole pivot table, then [Ctrl-C] to copy.
57. Click in cell G30 and [Ctrl-V] to paste.
58. In the new pivot table, drag Date to the Filters area.
59. Use the pull down for the Date filter and choose just March.

Note** For Weekly figures, choose Days then set the Number of days: to 7.

60. Going back to the pivot table in cell G2 (still on Sheet1), Double click on Mar in G6 -
the Show Detail dialog box appears.
61. From the available fields choose Amount then click [OK].
Note** You can show the source row data that was used in the cell calculation by double
clicking on the cell. Excel will then copy the source row information into a new, separate
worksheet.

62. Double click on the $8.65 in cell H18. Rename the resulting sheet tab to Sarah.

Built-in Styles
Excel has a variety of pre-defined layouts for pivot tables built into the program.
63. Click on the Pivot Table Tools Design tab on the Ribbon.
64. Make the top pivot table on the Accounts worksheet Pivot Style Light 14 (the first option
showing). Make the top table on the Sheet1 worksheet Pivot Style Medium 6.
65. For the top table on the Sheet1 worksheet, also choose “Banded Rows” from the
PivotTable Style Options area.

Updating a Pivot Table


When working with pivot tables, it appears that the table interacts dynamically with the
spreadsheet’s data. This is not actually the case. Pivot tables use a copy of the data values,
which are held in temporary memory. This means that if you change any of the raw data
values, the pivot table will not reflect the changes, instead you have to refresh the data for the
new values to be included.

66. On Sheet1, change Sarah’s travel in cell D30 from $63 to $3.75.
67. To update the pivot table, right click on a data field (ex. cell G10) and choose Refresh
(you can also choose Refresh from the Data area of the Pivot Table Analyze tab.

For more tips on Pivot Tables, watch the lecture video.

Pivot Charts
You can also make charts of pivot data.

68. Click in cell A6 on Sheet1.


69. On the Insert tab on the Ribbon, click on the [PivotChart] button in the Charts area.
70. Choose the PivotChart option.
71. Put the chart in a new worksheet.
72. In the PivotChart Fields area, drag Category to Axis, Amount to Values and Date to
Legend. Note that it creates a pivot table and a chart of the data at the same time.
73. Move the chart so it is below the table data.
74. Click in the pivot table area (now above the chart) and, from the Analyze tab of the
PivotTable Tools area, click on Insert Slicer.
75. Choose Employee from the Slicer box and click [OK].
76. Move the slicer box to the right of the Pivot Table and Pivot Chart.
77. To filter the chart and table data by individual employees, you can now use the Slicer!
To clear the filter, use the Clear Filter button at the top right of the Slicer window.
Rename the worksheet tab Slicer.
78. Rename your Sheet1 tab to Pivot.
Click on the File tab, save the file to your computer, then answer the pivot tables assessment
based on your file and/or comprehension of the lecture.

You might also like