Pivot Tables - Googlegeneva.libnet.info/images/pdfs/geneva/Class...
Transcript of Pivot Tables - Googlegeneva.libnet.info/images/pdfs/geneva/Class...
1 *
ClassDescriptionThis is an introduction to using Pivot Tables in spreadsheets, focusing on Microsoft Excel. Attendees should have a good
basic knowledge of spreadsheets.
ClassLengthOne and one‐half (1½) hours
IntroductionPivot Tables make analysis of a spreadsheet much easier than poring through countless rows of information, often with
just a little bit of information on each row. Pivot Tables can aggregate information and show a new perspective with just
a few clicks. They can be thought of as a summary table of the original spreadsheet.
Objectives Learn how to create a Pivot Table from a spreadsheet’s rows and columns
Learn how to add and remove rows, and add and remove columns from a Pivot Table
Learn how to change the calculations in a Pivot Table
Learn how to quickly change formatting of a Pivot Table’s figures
Thisisahandoutforyoutokeep.Pleasefeelfreetouseitfortakingnotes.
Pivot Tables
2 *
CreatingandManipulatingaPivotTableBefore creating a Pivot Table, you need data with which to work. Open the
PivotTableWorksheet file from Documents. It contains fictitious information
with the following fields:
Voter Number (Voter Num)
Precinct (Precinct)
Age Group (Age Group)
Last election in which a vote was cast (Last Voted)
How many years they have been a registered voter (Years Registered)
Ballot status (Ballot Status)
With just one of the cells with data active (selected) or with all the cells with data selected,
switch to the INSERT ribbon and in the Tables group on the far left side of the ribbon, click
the PivotTable icon.
You should see the Create PivotTable dialog box as
shown at left. For this exercise, it should have
Sheet1!$A$1:$G$4001 in the Table/Range field.
Although you can place the Pivot Table on the
same worksheet, the default of creating a new
worksheet is strongly recommended.
The checkbox next to ‘Add this data to the Data
Model’ is for adding multiple tables/ranges to a Pivot Table. We won’t be using
this feature. Click the OK
button when ready.
You should have a new
worksheet created (‘Sheet2’),
two temporary ribbons
(PIVOTTABLE TOOLS – ANALYZE
and PIVOTTABLE TOOLS – DESIGN)
with the first one active, an
area where the Pivot Table will
be created on the left side of
the worksheet and a panel on
the right side labelled
‘PivotTable Fields’ which, like
all panels, can be dragged to a
floating position (even outside
the Excel window) or to the left
side.
Use this icon: to select a range of cells to be used for the Pivot Table. You can also enter the range to be used directly into the field. If configured, you can select ‘Use an external data source’.
Data comes first! Pivot Tables can only produce results as good as the raw data. Ensuring good data in the spreadsheet is essential.
3 *
Although you can place checkmarks next to the fields you want to use in your Pivot Table, Microsoft Excel’s ‘guesses’ as
to where you want to use it are frequently incorrect. It is usually easier to drag the field from the top section into the
lower sections where you want the data to be.
After dragging the ‘Party’ field
into the Columns section, the
‘Precinct’ field into the Rows
section, and the ‘Voter Num’
field into the Values section,
you should have something like
this image.
Microsoft Excel has ‘guessed’ I
want the ‘Voter Num’ field
treated as numbers to be
added together! What we want
is a count of the voters. This
can be easily accomplished.
Click the down‐pointing
triangle to the right of the ‘Sum
of VOTE NUM’.
A menu of choices will open,
click on ‘Value Field Settings…’.
This opens the Value Field Settings dialog box
(shown at left). Since we want a count of the
voters instead of a total of their ID numbers, click
on the ‘Count’ option.
This will change the ‘Custom Name’ from ‘Sum of
VOTER NUM’ to ‘Count of VOTE NUM’.
Click the OK
button. (The result is on the next page.)
4 *
Here is our first Pivot Table,
showing the number of voters
by party by precinct.
One of the strengths of Pivot
Tables is the ability to change
the way information is
presented.
If we want to know the
percentage of each party in
each precinct, instead of just
raw counts, we only need to
right click on any of the values
in the Pivot Table to open a
context menu, move the
mouse pointer to ‘Show Values
As’ to open its submenu, then
move to ‘% of Row Total’ and
click on it.
The result will be something like this:
With this view, you can quickly identify the precinct
where Republican voters are in the majority.
If, instead of selecting ‘% of Row Total’, we select ‘%
of Column Total’, we can see how much each precinct
means to each party (next page).
5 *
Of course, politicians really care about actual votes,
so right click in the region of percentages, move to
the ‘Show Values As’ to open its submenu, then click
on ‘No Calculation’. (The Pivot Table should again be
like the image at the top of the previous page.)
What if we want to limit our look to those who
voted in the previous two elections? This is where
Filters are used. Drag the ‘Last Voted’ field into the
Filters section.
None of the numbers have changed, but cells A1
and B1 have gained information for filtering. Cell A1
contains the name of the field for filtering; cell B1
contains the contents of the
filter with a down‐pointing
arrow for a drop down menu.
Click on the arrow to open the
menu:
Since we want the last two
elections, place a checkmark
next to ‘Select Multiple Items’
so we can select the items we
want. Remove the checkmarks next to the elections
in 2010 and 2012, then click the OK button.
6 *
The Pivot Table is updated with
the filter just selected and
applied.
Additional filters can be added.
After dragging the ‘Age Group’
field into the Filters section,
and then selecting ages above
51, we get this:
Removing items from the
Filters section or Columns
section or Rows section or
Values section is easy. Just
drag it out of the section with
the mouse and then release.
7 March 2016
UsingConditionalFormattingtoHighlightValuesSuppose the Republicans only have enough resources to target five precincts. They want to know which five precincts
have had the most Republican voters the past two elections. They don’t want to filter by age group. So we will drag the
‘Age Group’ out of the Filters section. Next, select the cells in the Republican column for each of the 23 precincts (it
should be cells F6 through F28). Then, switch to the HOME ribbon, find the Styles group, and click on Conditional
Formatting, slide down to ‘Top/Bottom Rules’, then over to ‘Top 10 Items…’.
The Top 10 Items dialog box opens with the ten largest numbers
highlighted (actually 12 items here because of a three‐way tie for 10th
place). Click on the down‐pointing arrow to the right of 10 five times to
reduce the value to 5 (or click on the 10 and enter 5). As the number is
reduced, the number of highlighted cells is reduced. If desired, change the
color scheme with the drop‐down menu:
You should see something like this;
the highlighted cells clustered
towards the bottom.
Questions? Feel free to contact Ross Valentine at [email protected] or call the library at 630.232.0780
Tip: Conditional formatting can be used anywhere in a spreadsheet — it isn’t limited to Pivot Tables.