Pivot Tables

You might also like

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 16

Creating a Pivot Table and Pivot Chart

Select a cell in the range that contains the data you would like to analyze.
Each row must have a different observation, each column must have a different variable.
Insert - Pivot Chart - Pivot Chart

Either options will get you both a pivot chart and a pivot table.

Click on the chart or the table to activate the


contextual Pivot Table Fields menu

Or

Click on the chart and go to: PivotChart


Tools -Analyze - Field List

Drag an ID field or any other field from the top section of the menu to "Sum of Values" in the bottom of the menu.

If you selected a numerical variable, you may want to toggle from "Sum of {your field}" to "Count of {your field}" depending on your analysis.
Other options are also available and might be appropriate to specific situations - use with caution.

Click on the drop-down arrow besides your


field

Drag other fields into the "Rows" and "Columns" or "Axis" and "Legend" areas of the bottom menu to generate charts.

Drag other fields into "Filter" to filter data - making a subset of the data according to your specified criteria.
PLEASE NOTE: filtered fields will stay filtered even after dragging away from the "filter area".
Return to the "filter area" and remove the filter by clicking "All", or click on the drop-down arrow that appears when you hover over a field in "PivotTable
Fields".
Filters are identified in the PivotTable Fields list with the filter symbol.

Back to Top
Formatting a Pivot Chart
Click on a chart to activate the contextual PivotChart Tools ribbon.
Click on a chart

Click on "Add Chart Element" to add or remove various aspects of the chart.
PivotChart Tools - Design
Some more advanced options are hiding under "More [type of chart element] options.
Modify the look as desired -- and use the "bar chart" icon to set advanced settings for the chart.

Click on a "Quick Layout", Change Colors" or "Chart Styles" to quickly modify the look of the chart.
PivotChart Tools - Design

PivotChart Tools - Analyze Go to "Field Buttons - Hide All" to remove PivotChart buttons from your chart.

To prevent the chart from constantly resizing as you make updates, remove "Autofit columns on update" from the "Options" menu
PivotChart Tools - Analyze

Back to Top
Modifying Chart Types
Click on a chart to activate the contextual PivotChart Tools ribbon.
Click on a chart

PivotChart Tools - Design


Back to Top
Creating new fields from an existing field (especially useful with dates/times)

Activate the contextual PivotTable Fields


menu (click on chart OR Tools - Analyze -
Field List) Remove all fields except the field in the "Sum of Values" area.
Drag the field to be used for extraction in the "Rows" or "Axis" area.

Click on a chart to activate the contextual PivotChart Tools ribbon.


Click on a chart

Click on a cell in the first column of the Pivot Table

PivotTable Tools - Analyze

Select any desired categories and click on "Ok".


Fields will be added to your "PivotTable Fields" contextual menu.

Back to Top
Slicers and Timelines
WARNING: slicers and timelines are only available in the most recent versions of Excel and will not work when opened in older versions.

Click on a chart to activate the contextual PivotChart Tools ribbon.


Click on a chart

PivotChart Tools - Analyze

Select one or more variables to put into place "slicers".

Click (on a value in a slicer) Filter the pivot chart to only show data that corresponds to the selected value
Ctrl-Click (on values in a slicer) Select more than one value to use to filter the pivot chart.

Use Slicer Settings to change caption settings, sort order, and behavior of items with no data.
Slicer Tools (click on a slicer to activate)
Slicer Tools (click on a slicer to activate) Change the number of columns

Quickly change the look of the slicer - select one or two values to judge the appearance of unselected values

Works with date/time variables to create a draggeable "timeline".


PivotChart Tools - Analyze

Back to Top
Advanced Tweaks
Changing the order of data displayed in the chart
File - Options - Advanced - Edit Custom Lists
(near end of advanced screen) When alphabetical order does not display your data correctly, you can use custom lists to tell Excel in what order data should be displayed.
This will work when displaying data in Pivot Tables and Pivot Charts.
This Excel File already contains a few custom series, take a look and explore!

Filling in categories to give your data the correct format


You will sometimes need to fill in categories so that every row has the category value listed.

In the example below, "Teaching", "Community - Large", and "Community - Medium" need to be repeated on every row in order to create a pivot table.

Teaching

Community - Large

Community - Medium

Starting from the first cell that contains a category, select ALL affected cells in the column of your table (so all blanks + categories at once).
Hit F5 OR go to the Home ribbon - Editing section - Find & Select - Go to special. Select "Blanks".
Type "=" (no need to click anywhere, just start typing), hit the "up" arrow on your keyboard, and then do Ctrl-Enter.
The series should fill in - please note that formulas will be inserted in the table.

Moving Charts
You can't delete the pivot table, but you can leave it behind in another worksheet, and hide the worksheet.

Click on a chart to activate the contextual PivotChart Tools ribbon.


Click on a chart
PivotChart Tools - Design

Connecting a slicer to a second pivot chart


Start by creating a slicer connected to your first chart.
Select the pivot tables of all pivot charts to connect.

Click on slicer
Instructions

The city of Halifax offered free knitting classes - with voluntary donations - to children aged 3 to 18. Parents were instructed to pick one of three nights: Monday, Wednesday,
or Friday. The city would like to learn more about who attended the classes:
Question 1: What are the names of the children aged 11 years or older that registered for the Monday class?
Question 2: On what day of the week did the city receive the highest amount of donations?
Question 3: During what day of the week did most registrations happen? At what time of the day did most registrations happen?
Question 4: Which class (day of the week) was most popular for the girls? Which class (day of the week) was most popular for the boys?
Question 5: Which day of the week was most popular for children aged 10 years or younger and what was the gender distribution on that day?
Question 6: What was the percentage of children from each age groups registed on Monday? Wednesday? Friday?

Work through the following series of steps. Eventually, you will have a pivot table and slicers similar to those displayed in the Expected Result worksheet and will be able to
answer any other questions the city might ask you about the data.
Question 1 - Creating a Pivot Chart and Pivot Table
Question 1: What are the names of the children aged 11 years or older that registered for the Monday class?
Click on any cell in range A1 to G65 in the 'Exercise' worksheet. Click on the "Insert" ribbon and select "Pivot Chart - Pivot Chart" or "Pivot Table - Pivot Chart" depending on your version
1 of Excel. Click on "Ok".
2 Click on the chart or pivot table object -- the "PivotTable Fields" menu should appear on the right of the screen.
3 Drag "Donation" from the top of "PivotTable Fields" to "Sum Values" in the bottom right.
4 Drag "Name" to the "Rows" or "Axis" area.
5 Drag "Age Groups" and "Class Day" to "Filters".
6 Apply the necessary filters to reveal the answer - best seen in the pivot table, but you can also resize the pivot chart.
Question 2 - Dynamically Updating a Pivot Chart by Moving Fields
Question 2: On what day of the week did the city receive the highest amount of donations?
7 Remove filters on all variables - right now, you probably have filters on "Age groups" and "Class Day".
8 Remove "Name" from the Rows/Axis area.
9 Make sure that "Sum of Donations" is in the "Sum of Values" area.
10 Drag "Class day" to the Rows/Axis area.
11 Drag "Gender" to the Columns/Legends area.
12 Look at the resulting chart to find the answer.
13 Experiment with dragging fields around: put two variables in the Rows/Axis area and then change the order, put a variable in the Columns/Series area, etc.

Julie.Marcoux@dal.ca - Dalhousie Libraries – Excel Pivot Tables


Question 3 - Grouping Fields to Create New Fields
Question 3: During what day of the week did most registrations happen? At what time of the day did most registrations happen?
Either change "Sum of Donations" in the "Sum of Values" area to "Count of Donations" (by clicking on the dropdown arrow, and selecting the right option in "Value Field Settings") OR
14 remove "Sum of Donations" and replace with "Name" in the "Sum of Values" area.

15 Make any modifications needed so that the Rows/Axis area contains only "Day of week of registration" - that answers the first part of question 3. But what about the time of day?
16 Modify so that the Rows/Axis area contains only "Time of registration".
17 Click on any cell containing a date and time in the pivot table - in column A. In the "Analyze" ribbon, click on "Group selection". Select "Hours", "Days", and "Months".
18 Look in the Rows/Axis area. Your new variables should be there. If there is not a "Hour" variable, "Time of registration" now contains hours of the day.

19 Make any modifications needed so that you get a chart that shows the number of registrations at each hour of the day. What was the most popular time of day for registrations?
Question 4 - Slicers
Question 4: Which class was most popular for the girls? Which class was most popular for the boys?
Go to the "Analyze" ribbon and click on "Insert Slicer". Add slicers for "Class Day", "Age Groups", "Gender". WARNING: slicers are only available in the most recent versions of Excel and
20 will not work when opened in older versions.
Arrange the fields of your pivot chart so that clicking on "Girls" in the gender slicer reveals the most popular day of the week for classes for girls, and clicking on "Boys" does the same for
21 the boys. Thanks to the slicer, the gender variable does not necessarily have to be in an area of your resulting chart.
22 Look at the resulting charts to find the answer.
23 Experiment with the slicers by clicking on various values, and removing filters.
Question 5 - Chart Types
Question 5: Which day of the week was most popular for children aged 10 years or younger and what was the gender distribution on that day?
24 Place "Class Day" in the Rows/Axis area, and "Gender" in the Columns/Legends area.
25 Click on the pivot chart. Go to the Design ribbon and click on "Change Chart Type".
26 Select the "Stacked Bar" chart.
27 Click on the relevant slicers to find the day of the week that was most popular for children aged 10 years or younger.
Question 6 - Chart Types
Question 6: What was the percentage of children from each age groups registed on Monday? Wednesday? Friday?
28 Place variables in appropriate areas of Pivotchart Fields.
29 Choose a pie chart graphic.
Go to the Design ribbon, click on "Add chart elements", select "Data Labels", click on "More data label options", click on the bar chart icon under "label options", select "Percentage" and
30 un-select "Value".
31 Play with the slicers until you have your answers.

Julie.Marcoux@dal.ca - Dalhousie Libraries – Excel Pivot Tables


Name Class Day Age Groups Gender
Adam Strange Friday 6 to 10 years old Boy
Barbara Gordon Monday 0 to 5 years old Girl
Barry Allen Monday 6 to 10 years old Boy
Beta Ray Bill Monday 0 to 5 years old Boy
Billy Batson Wednesday 11 to 15 years old Boy
Branklin Benjamin Richards Wednesday 6 to 10 years old Boy
Bruce Banner Friday 0 to 5 years old Boy
Bruce Wayne Friday 11 to 15 years old Boy
Buffy Summers Friday 6 to 10 years old Girl
Carol Danvers Monday 0 to 5 years old Girl
Cassandra Cain Monday 16 to 18 years old Girl
Charles Xavier Wednesday 11 to 15 years old Boy
Clark Kent Wednesday 0 to 5 years old Boy
Clint Barton Friday 11 to 15 years old Boy
Damian Wayne Friday 16 to 18 years old Boy
Daniel Garrett Wednesday 16 to 18 years old Boy
Diana Prince Monday 11 to 15 years old Girl
Dinah Lancel Monday 6 to 10 years old Girl
Donna Troy Wednesday 16 to 18 years old Girl
Elektra Natchios Wednesday 6 to 10 years old Girl
Emma Frost Friday 0 to 5 years old Girl
Felicy Hardy Friday 0 to 5 years old Girl
Guy Gardner Friday 16 to 18 years old Boy
Hal Jordan Wednesday 0 to 5 years old Boy
Helen Parr Monday 0 to 5 years old Girl
Helena Rosa Bertinelli Friday 11 to 15 years old Girl
Henry Jonathan Pym Friday 11 to 15 years old Boy
Hope Summers Monday 11 to 15 years old Girl
James Howlett Friday 11 to 15 years old Boy
Jason Todd Wednesday 11 to 15 years old Boy
Jay Garrick Monday 0 to 5 years old Boy
Jean Grey Monday 6 to 10 years old Girl
Jeanne-Marie Beaubier Monday 0 to 5 years old Girl
Jessica Jones Monday 16 to 18 years old Girl
John Jones Wednesday 0 to 5 years old Boy
John Stewart Wednesday 16 to 18 years old Boy
Kara Zor-El Monday 16 to 18 years old Girl
Katherine Elizabeth Bishop Monday 0 to 5 years old Girl
Kendra Saunders Friday 11 to 15 years old Girl
Kurt Wagner Friday 11 to 15 years old Boy
Mary Elizabeth Kane Monday 6 to 10 years old Girl
Megan Morse Friday 11 to 15 years old Girl
Michael John Carter Monday 0 to 5 years old Boy
Natalia Romanova Wednesday 11 to 15 years old Girl
Peter Parker Friday 16 to 18 years old Boy
Pietro Maximoff Friday 16 to 18 years old Boy
Reed Richards Monday 6 to 10 years old Boy
Remy Etienne LeBeau Friday 11 to 15 years old Boy
Richard John Grayson Wednesday 16 to 18 years old Boy
Robert Parr Friday 6 to 10 years old Boy
Roy Harper Monday 16 to 18 years old Boy
Salu Digby Wednesday 6 to 10 years old Girl
Selina Kyle Monday 16 to 18 years old Girl
Stephanie Brown Wednesday 11 to 15 years old Girl
Steven Rogers Friday 6 to 10 years old Boy
Susan Storm Richards Wednesday 6 to 10 years old Girl
Theodore Kord Monday 6 to 10 years old Boy
Thor Odinson Monday 16 to 18 years old Boy
Tim Drake Monday 16 to 18 years old Boy
Victor Shade Monday 11 to 15 years old Boy
Wally West Friday 16 to 18 years old Boy
Wanda Maximoff Friday 16 to 18 years old Girl
Zatanna Zatara Monday 16 to 18 years old Girl
Time of registration Day of week
Donation
11/9/2015 10:59 Monday $13
11/10/2015 9:43 Tuesday $5
11/9/2015 16:30 Monday $11
11/15/2015 11:51 Sunday $11
11/10/2015 10:27 Tuesday $6
11/15/2015 11:59 Sunday $12
11/15/2015 11:18 Sunday $9
11/9/2015 16:02 Monday $90
11/14/2015 22:18 Saturday $15
11/15/2015 11:21 Sunday $10
11/9/2015 13:22 Monday $14
11/9/2015 11:52 Monday $13
11/13/2015 9:52 Friday $14
11/13/2015 16:28 Friday $9
11/15/2015 12:47 Sunday $10
11/15/2015 2:41 Sunday $9
11/14/2015 16:24 Saturday $11
11/15/2015 11:46 Sunday $11
11/14/2015 13:08 Saturday $10
11/14/2015 13:39 Saturday $10
11/12/2015 20:13 Thursday $11
11/9/2015 18:52 Monday $9
11/14/2015 14:07 Saturday $9
11/13/2015 17:07 Friday $14
11/15/2015 11:00 Sunday $7
11/14/2015 14:59 Saturday $8
11/12/2015 16:44 Thursday $8
11/14/2015 20:06 Saturday $13
11/8/2015 20:03 Sunday $6
11/9/2015 9:30 Monday $5
11/12/2015 13:55 Thursday $12
11/14/2015 19:03 Saturday $5
11/14/2015 15:14 Saturday $12
11/12/2015 13:27 Thursday $15
11/9/2015 10:39 Monday $12
11/13/2015 17:33 Friday $6
11/12/2015 13:14 Thursday $14
11/14/2015 15:16 Saturday $6
11/13/2015 19:59 Friday $6
11/9/2015 8:26 Monday $6
11/15/2015 10:49 Sunday $11
11/15/2015 11:00 Sunday $9
11/13/2015 10:06 Friday $6
11/15/2015 10:06 Sunday $6
11/14/2015 13:44 Saturday $8
11/14/2015 14:08 Saturday $9
11/15/2015 11:17 Sunday $9
11/15/2015 13:02 Sunday $13
11/15/2015 12:34 Sunday $13
11/14/2015 22:39 Saturday $11
11/9/2015 18:54 Monday $10
11/14/2015 12:09 Saturday $12
11/14/2015 15:13 Saturday $8
11/14/2015 22:39 Saturday $11
11/10/2015 20:07 Tuesday $15
11/15/2015 10:28 Sunday $15
11/15/2015 12:38 Sunday $9
11/15/2015 10:11 Sunday $8
11/10/2015 9:44 Tuesday $15
11/15/2015 12:58 Sunday $6
11/15/2015 12:10 Sunday $14
11/10/2015 10:28 Tuesday $6
11/15/2015 10:49 Sunday $7
Count of Name Gender This shape represents a slic
Class Day Boy Art ofGirlKnittiTotal
ng Result
Registrati on 2010 or later.
Monday 10 15 25
40 If the shape was modified i
Wednesday 10 6 16
workbook was saved in Ex
Friday
35 15 7 22 used.
Total Result 35 28 63
30

25
Gender Boy
Girl
20

15
This shape represents a slic
10 Slicers are supported in Exc
2010 or later.
5
If the shape was modified i
0 earlier version of Excel, or
Monday Wednesday Friday Total Result the workbook was saved in
Excel 2003 or earlier, the sl
This shape represents a slicer. Slicers are supported in Excel 2010 or later.
cannot be used.
If the shape was modified in an earlier version of Excel, or if the workbook was saved in Excel
2003 or earlier, the slicer cannot be used.
This shape represents a slicer. Slicers are supported in Excel
2010 or later.

If the shape was modified in an earlier version of Excel, or if the


workbook was saved in Excel 2003 or earlier, the slicer cannot be
used.

This shape represents a slicer. This shape represents a slicer.


Slicers are supported in Excel Slicers are supported in Excel
2010 or later. 2010 or later.

If the shape was modified in an If the shape was modified in an


earlier version of Excel, or if earlier version of Excel, or if
the workbook was saved in the workbook was saved in
Excel 2003 or earlier, the slicer Excel 2003 or earlier, the slicer
cannot be used. cannot be used.
14 of 16

Creating a Pivot Table and Pivot Chart


Select a cell in the range that contains the data you would like to analyze.
Each row must have a different observation, each column must have a different variable.

Insert - Pivot Chart - Pivot Chart

Click on the chart or the table to


activate the contextual Pivot
Table Fields menu
Or

Click on the chart and go to:


PivotChart Tools -Analyze - Field
List

Either options will get you both a pivot chart and a pivot table.

Drag an ID field or any other field from the top section of the menu to "Sum of Values" in the bottom of the menu.
If you selected a numerical variable, you may want to toggle from "Sum of {your field}" to "Count of {your field}" depending on your analysis.
Other options are also available and might be appropriate to specific situations - use with caution.

Click on the drop-down arrow


besides your field

Drag other fields into the "Rows" and "Columns" or "Axis" and "Legend" areas of the bottom menu to generate charts.

Drag other fields into "Filter" to filter data - making a subset of the data according to your specified criteria.
PLEASE NOTE: filtered fields will stay filtered even after dragging away from the "filter area".
Return to the "filter area" and remove the filter by clicking "All", or click on the drop-down arrow that appears when you hover over a field in "PivotTable
Fields".
Filters are identified in the PivotTable Fields list with the filter symbol.

Formatting a Pivot Chart


Click on a chart to activate the contextual PivotChart Tools ribbon.
Click on a chart

Click on "Add Chart Element" to add or remove various aspects of the chart.
PivotChart Tools - Design

Some more advanced options are hiding under "More [type of chart element] options.
Modify the look as desired -- and use the "bar chart" icon to set advanced settings for the chart.

Click on a "Quick Layout", Change Colors" or "Chart Styles" to quickly modify the look of the chart.
PivotChart Tools - Design

PivotChart Tools - Analyze Go to "Field Buttons - Hide All" to remove PivotChart buttons from your chart.

Julie.Marcoux@dal.ca - Dalhousie Libraries – DLI Atlantic Training 2016 – Session 2.7


15 of 16

To prevent the chart from constantly resizing as you make updates, remove "Autofit columns on update" from the "Options" menu
PivotChart Tools - Analyze

Modifying Chart Types


Click on a chart to activate the contextual PivotChart Tools ribbon.
Click on a chart
PivotChart Tools - Design

Creating new fields from an existing field (especially useful with dates/times)

Activate the contextual PivotTable


Fields menu (click on chart OR
Tools - Analyze - Field List) Remove all fields except the field in the "Sum of Values" area.
Drag the field to be used for extraction in the "Rows" or "Axis" area.

Click on a chart to activate the contextual PivotChart Tools ribbon.


Click on a chart

Click on a cell in the first column of the Pivot Table

PivotTable Tools - Analyze

Select any desired categories and click on "Ok".


Fields will be added to your "PivotTable Fields" contextual menu.

Slicers and Timelines


WARNING: slicers and timelines are only available in the most recent versions of Excel and will not work when opened in older versions.

PivotChart Tools - Analyze

Select one or more variables to put into place "slicers".

Click (on a value in a slicer) Filter the pivot chart to only show data that corresponds to the selected value

Ctrl-Click (on values in a slicer) Select more than one value to use to filter the pivot chart.

Use Slicer Settings to change caption settings, sort order, and behavior of items with no data.
Slicer Tools (click on a slicer to
activate)

Julie.Marcoux@dal.ca - Dalhousie Libraries – DLI Atlantic Training 2016 – Session 2.7


16 of 16

Slicer Tools (click on a slicer to


activate) Change the number of columns

Quickly change the look of the slicer - select one or two values to judge the appearance of unselected values

Works with date/time variables to create a draggeable "timeline".


PivotChart Tools - Analyze

Advanced Tweaks
Changing the order of data displayed in the chart

File - Options - Advanced - Edit


Custom Lists (near end of
advanced screen) When alphabetical order does not display your data correctly, you can use custom lists to tell Excel in what order data should be displayed.
This will work when displaying data in Pivot Tables and Pivot Charts.
This Excel File already contains a few custom series, take a look and explore!

Filling in categories to give your data the correct format


You will sometimes need to fill in categories so that every row has the category value listed.

In the example below, "Teaching", "Community - Large", and "Community - Medium" need to be repeated on every row in order to create a pivot table.

Teaching

Community - Large

Community - Medium

Starting from the first cell that contains a category, select ALL affected cells in the column of your table (so all blanks + categories at once).
Hit F5 OR go to the Home ribbon - Editing section - Find & Select - Go to special. Select "Blanks".
Type "=" (no need to click anywhere, just start typing), hit the "up" arrow on your keyboard, and then do Ctrl-Enter.
The series should fill in - please note that formulas will be inserted in the table.

Moving Charts
You can't delete the pivot table, but you can leave it behind in another worksheet, and hide the worksheet.

Click on a chart to activate the contextual PivotChart Tools ribbon.


Click on a chart

PivotChart Tools - Design

Connecting a slicer to a second pivot chart


Start by creating a slicer connected to your first chart.Click on slicer and "Report Connections".
Select the pivot tables of all pivot charts to connect.

Julie.Marcoux@dal.ca - Dalhousie Libraries – DLI Atlantic Training 2016 – Session 2.7

You might also like