0% found this document useful (0 votes)
83 views23 pages

Excel 2007 Pivot Tables Manual

This document provides an overview of pivot tables in Excel 2007, including how to create pivot tables, arrange data fields, change value calculations and formatting, add calculated fields, sort and filter data, refresh pivot tables, and create pivot charts. Key steps include selecting a data range, dragging fields to the row, column, and value areas, customizing calculations and formats, and inserting formulas to derive new fields for analysis. Pivot tables summarize and rearrange large datasets to help users analyze relationships and trends.

Uploaded by

Ajay Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views23 pages

Excel 2007 Pivot Tables Manual

This document provides an overview of pivot tables in Excel 2007, including how to create pivot tables, arrange data fields, change value calculations and formatting, add calculated fields, sort and filter data, refresh pivot tables, and create pivot charts. Key steps include selecting a data range, dragging fields to the row, column, and value areas, customizing calculations and formats, and inserting formulas to derive new fields for analysis. Pivot tables summarize and rearrange large datasets to help users analyze relationships and trends.

Uploaded by

Ajay Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Excel 2007

PivotTables
Contents
PivotTables......................................................................................................................... 1
PivotTable datasets 1
Creating a PivotTable 2
Arranging your data 3
Changing the way values are displayed 4
Calculated Fields ............................................................................................................... 6
Calculated Items ................................................................................................................ 8
Formatting values 9
Grouping data 10
Sorting and Filtering Data 13
Refreshing a PivotTable 14
Extending the dataset 15
Dynamic Range Names ................................................................................................... 16
Applying the Named Range to a new PivotTable 17
Applying the Named Range to an existing PivotTable 17
Formatting PivotTables 18
GetPivotData Function 18
PivotCharts ....................................................................................................................... 19
Creating a PivotChart with a PivotTable 19
PivotTables
A PivotTable organises and summarises large amounts of data. The data in one or more
columns (also known as fields) in your dataset can become row and column labels in the
PivotTable. The data in one column is usually chosen for the Values which are
summarised in the centre of the table using a specific calculation. It is called a PivotTable
because the headings can be rotated around the data to view or summarise it in different
ways. You can also filter the data to display just the details for areas of interest.
You can alternatively choose to create a PivotChart which will summarise the data in chart
format rather than as a table.
The source data can be:
An Excel worksheet database/list or any range that has labelled columns. We will
use Excel worksheets as examples in this manual.
A collection of ranges to be consolidated. The ranges must contain both labelled
rows and columns.
A database file created in an external application such as Access.
The data in a PivotTable cannot be changed as they are the summary of other data. The
data itself can be changed and the PivotTable recalculated thereafter. However,
formatting changes such as bold, number formats, etc. can be made directly to the
PivotTable data.

PivotTable datasets
A good dataset for creating a PivotTable will
have data organised into columns with a
heading at the top of each column. There
should be no blank rows in the data so it is
all organised into one rectangular block.
Each row is a record and each column a
field. In the data set on the right, each row
represents a stationery order placed by a
department.
Columns where the values are repeated
within the column are ideal for PivotTable
row or column labels. So for example, in
the dataset on the left, Dept, Term or
Product might be placed in the row or
column headings. Amount might be used
as the Values to be summarised in the
centre of the PivotTable.

Example
If Dept is used as the row labels, each unique
value in that column will appear down the left-
hand side of the PivotTable. Similarly if
Product is used as the column labels then Paper and Toner will appear across the top of
1
the PivotTable. Where a particular value in a row and a particular value in a column
intersect, the data in the Amount field is summarised in the centre. By default the
calculation used is Sum. So, for example, where Geography and Paper intersect the total
amount of Paper ordered by Geography will be displayed i.e. 26.

Creating a PivotTable

1. Click anywhere within the range of data you wish to use to create your
PivotTable.
2. From the Insert tab select PivotTable.
Excel will display the Create PivotTable dialog box, automatically select the entire
range and add the reference for that range to the Table/Range box.
3. Select New Worksheet or Existing Worksheet depending on where you want your
PivotTable to appear.
4. If you choose to put the
PivotTable into the existing
worksheet, you need to make
sure you tell the wizard where
to place it. The easiest way to
do this is to click into an area
in the existing spreadsheet.
The cell reference will appear
in the Location box.
5. Click on the OK button.
A blank PivotTable and
PivotTable Field List will be
displayed. Two new
PivotTable Tools tabs
become available on the Ribbon: Options and Design. Any column headings become
fields in the Field List.
Note that the Field List and additional Tabs on the Ribbon only appear when you click on
the PivotTable.

2
Arranging your data

1. From the Field List, drag the fields with the data you want to display in rows to the
area on the PivotTable diagram labeled Drop Row Fields Here or into the Row
Labels box.
2. Drag the fields with the data you want to display in columns to the area labeled Drop
Column Fields Here or into the Column Labels box.
3. Drag the fields that contain the data you want to summarize to the area labeled Drop
Value Fields Here or into the Values box. Excel assumes Sum as the calculation
method for numeric fields and Count for non-numeric fields.
4. If you drag more than one data field into rows or into columns, you can re-order them
by clicking and dragging the columns on the PivotTable itself or in the boxes.
5. To rearrange the fields at any time, simply drag them from one area to another.
6. To remove a field, drag it out of the PivotTable report or untick it in the Field List.
Fields that you remove remain available in the field list.
Example

3
Changing the way values are displayed
Changing the way data is summarised
By default, Excel will use a Sum function on
numeric data and Count on non-numeric to
summarise or aggregate the data. If you have
any text entries amongst a column containing
mainly numbers, Excel will use the Count option.
To change this:
1. Click on the field you want to change (on the
PivotTable itself or in the areas below the
Field list)
2. Click on Field Settings on the PivotTable
Tools Options tab
The Field Setting dialog box will be displayed
as shown right.
3. Select the appropriate calculation.
For example, change the calculation from Sum to Average (see below for example).
OR
Right-click in the PivotTable and select Summarize data By: and select from the list of
calculations.

Example
In the example below, the data set contains student information including numerical data
such as A-Level Points (although this column contains text, you can still do most
calculations) and Fees Paid.
The PivotTable shows the average number of A-Level points for the students attending
each college.

4
This example shows Average A-Level Points by
College.
To change the number format: Right-click in the
PivotTable, and choose Number Format

Adding additional calculations


To display more than one calculation in the Values area, add the same Field twice. In the
example shown below, the Sum and Count are being shown for the Fees Paid to each
College. Count of Fees Paid is the number of fees paid to each College.
Field List and Areas
Section

5
Calculated Fields
You can have additional calculations, which are not part of the source data, in your
PivotTable. You will use the fields containing numeric data to create new fields. They will
become part of the PivotTable and can be used in further calculations.
The following example shows a new field called Increase created by using the field Fees
Paid and multiplying by 10%. The new field (Increase) can then used in another
calculation.

Click anywhere in PivotTable


a. On the Options tab, Tools group click on the Formulas button,

then Calculated Field


b. Type in name you want to give your new field eg: Increase
c. Then in Formula field the calculation required eg =’Fees Paid’*10%

NB: You can type in the field names you want use in the calculation, or
select them from the list and use the Insert Field button

Formulae can be modified =’Fees paid’*7% and calculations will be


updated immediately.

You can use the new field to create another calculated field:
Name: NewFee
Formula=Fees Paid+Increase

6
To Delete or Amend a Calculated Field
1. In the Insert Calculated Field dialog box, Click on drop-down
at the side of the Name: field and select field to amend or
delete.

2. Click on Modify to amend.

3. Click on Delete to remove.

7
Calculated Items
This is a feature which allows you to create calculations within the PivotTable using the
summary figures there. For example, you may want add two fields together to form
another heading.

The example below shows new calculated items (field heading NorthEast and SouthWest)
which add together North and East sales figures and South and West figures respectively.

1. Start by clicking in the column or row heading which you want to include in the
calculation
2. In Fields: click on the field name which contains the items you want to use in you
formula
3. Select the item you want from the Items: list and click on the Insert Item button
4. Build up your formula using the fields and items as required

Delete or modify calculated items by clicking on the drop-down at the side of the
Name: field

8
Formatting values
1. Display the Field Settings dialog box as shown above.
2. Click on the Number Format button.
3. Select the Category you want and set any options.
For example, select Number and enter the number of decimal places to display the
data to.
4. Click OK and OK again and your cells
will be reformatted.

Displaying values as a
percentages:
1. Display the Field Settings dialog box
as shown above.
2. Click on the Show Values As tab.
3. Select Percentage of Row Total or
Percentage of Column Total
Example
In the example below, products ordered (paper and toner) are shown for each department
as a percentage of the total for all departments. This is done by displaying values as a
percentage of the column total.

Helpful hint:
The Field Settings dialog box can be used to change the name of any Field in the PivotTable. For example,
this can be used to change the name of Dept to Department.

9
Grouping data
Data can be summarised into higher level categories by grouping items within PivotTable
fields. Depending on the data in the field there are three ways to group items:
Group selected items into custom categories.
Automatically group numeric items by a specific interval.
Automatically group dates and times by a specific interval.
Grouping selected items
1. Select the items you wish to group in a given row or column. Select
adjacent items by clicking and dragging, or non-adjacent items by selecting each item
whilst holding down the Ctrl key.
2. Click on the Group Selection button on the PivotTable Tools Options tab.
3. An additional column is created to the left (for row labels) or an additional row is
created above (for column labels) and a default name (e.g. Group1) is given to the
group.
The name can be changed in the Custom Name box in Field Settings or in the
Formula Bar.
4. Use the +/- buttons to expand and collapse the group.

Example
In the example below, some modules have been grouped by subject. The Statistics
group has been collapsed so that average results for Statistics are shown for both
modules STATB091 and STATB092.

Note that MODCODE2 is now another field in the Row Labels area and can be added or
removed like any other field.

10
Grouping numeric items into ranges

5. Select a single field item in the PivotTable.


6. Click on the Group Field button on the PivotTable Tools
Options tab.
7. Excel displays a dialog box in which it automatically
enters a start and end number based on the highest and
lowest values in your range. It also lists a number for the
intervals to group by.
8. Select an appropriate interval and click OK.
Example
In the example below, marks are grouped in intervals of 10 so, for example, you can see
that 1 candidate got between 40 and 49 marks in COMPB401 and 4 got between 50 and
59 marks.

11
Grouping date or time data
1. Select a single field item in the
PivotTable.
2. Click on the Group Field button on
the PivotTable Tools Options tab.
3. Excel displays a dialog box in
which it automatically enters a start
and end date. It also lists a choice
of intervals to group by.
4. Select an appropriate type of
interval (e.g. Months) and click OK.
If you select Days you can choose
the number of Days. You can
select more than one. For example if you select Months and Years, the data will be
grouped by year and then displayed for each month as shown.
Ungrouping
Click on the field you want to ungroup and click on the Ungroup button on the PivotTable
Tools Options tab to ungroup specific custom groups, click on the name of the group and
then the Ungroup button.
Default grouping for multiple values
Note that grouping automatically occurs where you have more than one Field in the same
area (Row or Column). In the example below, the Department and Term fields are both
added to the PivotTable as Row Labels. By putting the fields in the order Department then
Term, data is grouped by Department. Subtotals are automatically displayed for each
grouping i.e. by Department.
Note that you can remove Subtotals in the Field Settings dialog box.

12
Sorting and Filtering Data
Filtering allows you to display only certain data, either on the whole report or for a
particular field. Sorting allows you to sort columns or rows alphabetically or numerically.
Report filters
This allows you to filter all data out of a report if it has a value in a particular field.
1. Add the appropriate field to the Report Filter area.
The Field name will be displayed in a new area above the main part of the PivotTable.
2. Click on the drop-down arrow to the right of the word (All).
3. Tick the Select Multiple Items check box if you want to view multiple values.
4. Click on or tick the values to include in the PivotTable.
5. Click OK.
A small funnel symbol will appear to show that the report is filtered.
Example
In the example below, only data from Terms 1 and 2are displayed in the PivotTable:

Filtering row or column labels


To filter out (remove) a particular value from row or column labels:
1. Click on the drop down arrow next to the Field name.
2. Untick any items you wish to remove.
3. Select Value Filters to see more options such as Top 10.
Top 10 filters out a specific number of the highest values in the Value area.

In the example below, Top 10 on the Mark field is set to 5so it displays only the exam
results with the highest 5 values in the Grand total row i.e. the 5 exam results that
appear most frequently amongst candidates:

13
Sorting row or column labels:
1. Click on the drop down arrow next to the Field name.
2. Click on Sort A to Z or Sort Z to A for text, Sort Smallest to Largest or Largest to
Smallest for numeric data or Sort Oldest to Newest or Newest to Oldest for dates.

Refreshing a PivotTable
When data is changed in the PivotTable source list, the PivotTable does not
automatically recalculate. To refresh the table:
Select any part of the PivotTable.
5. On the PivotTable Tools Options tab, click on the Refresh button.
OR
Right-click in the PivotTable, and choose Refresh
You can also have your PivotTables refreshing every time you open the workbook. Click
on Options button on the Options tab and tick Refresh data when opening the file on
the Data tab:

14
Extending the dataset
If you add additional columns or rows to you will need to extend the data
source of the PivotTable to include them.
1. Click on the Data Source button on the PivotTable Tools Options tab.
2. Edit the range in the Table/Range box to include your entire dataset and click OK.

15
Dynamic Range Names
If more rows are added to your source data frequently, you can create a dynamic range
name which will automatically update to include any additional rows:
On the Formulas tab, select Name Manager, New
Type in the name you want to give your range eg: Data
Type in this function into the Refers to: field:
The syntax of this is: =OFFSET(Reference,rows,cols,[height],[width])
o =OFFSET(Data!$A$1,0,0,COUNTA(Data!$A:$A),15)
o Data!$A$1 - this is the top left corner of your range (including the sheet
name)
o 0,0, This would be how many rows down and column right from
Reference – in this case, not to move from A1
o COUNTA – This function will count the number of cells which are not empty,
thereby return the number of rows down to select
o 15 The number of columns in the table

16
Applying the Named Range to a new PivotTable
When you create a new PivotTable, you define the name as the source. Type the range
name in he Create PivotTable dialog box:

Applying the Named Range to an existing PivotTable


To use the new name in your PivotTable, you need to change the data source:
1. Select any cell in the PivotTable
2. On the Options tab, click the Change Data Source button:

3. Type in the dynamic range name. Or press F3 for a list of


names

17
Formatting PivotTables
Various options can be used to change the look of PivotTables. These can be found on
the PivotTable Tools Design tab. You can apply a PivotTable Style and choose
whether or not to have banded columns or rows (i.e. where rows or columns are coloured
in alternate shades.
Note that buttons to add or remove Subtotals and Grand Totals are also available on the
Design tab.

GetPivotData Function
The =GetPivotTable function will allow you to get information from the PivotTable by
referencing field names instead of cell references:
The syntax is: GETPIVOTDATA(data_field,pivot_table,field1,item1,field2,item2,...)

=GETPIVOTDATA("total sales",$A$3) Will return the Grand Total 1738900

=GETPIVOTDATA("total sales",$A$3,"area","south") Will return Total sales for


the Area South - 327600

=GETPIVOTDATA("total sales",$A$3,"area","south","salesperson","brown")
Will return Salesperson Brown’s Total Sales in the South Area - 123200

=GETPIVOTDATA("total sales",$A$3,"salesperson”,”smith) Will return


Salesperson Smith’s Total Sales - 398500

18
PivotCharts
When you create a PivotChart, Excel automatically creates an associated PivotTable. If
you have an existing PivotTable you can create a PivotChart based on it.

Creating a PivotChart with a PivotTable


1. Click anywhere within your dataset.
2. On the Insert tab, click on the PivotTable drop-down and select PivotChart from the
list.
3. Choose the dataset and location of the
PivotTable and PivotChart as you would to
create a new PivotTable (see Creating a
PivotTable on page 2).
A new blank PivotTable and PivotChart will be
created.
4. Click and drag Fields from the Field List onto
the different areas of the PivotTable in the usual
way. The PivotChart and PivotTable will both
be created simultaneously.
When the PivotChart is selected, the different
areas of the Chart are defined slightly differently to
the PivotTable areas. Row Labels are Axis
Fields (Categories) and Column Labels are
Legend Fields(Series) as shown right. The
resulting PivotChart is shown below:

700000

600000

500000

400000
F
300000
M
200000

100000

0
BUS EMPS HUMS L&E SSIS
SCIENCES

19
Adding a PivotChart to an existing PivotTable
You can also add a PivotChart if you have already created the PivotTable:
1. Click anywhere on the PivotTable.
2. On the Insert menu click on a type of Chart in the Charts group e.g. Column and then
select a particular style e.g. 2-D Column. A PivotChart will be added to your existing
PivotTable.
Note that some Chart types (for example Pie Charts) are not suitable for PivotTables
because they can only show two variables.

Formatting PivotCharts
PivotCharts can be formatted in the same way as any other Chart in Excel.

20
PivotTable Exercise
1. Open file Sales.xlsx

2. Create a Pivot Table which shows sales of products by category for all
the regions. It should look like the one below:

3. Add the Salesperson field to the Report Filter to enable you to see the
sales figures for each Salesperson.

4. What was the value of Salesperson Green’s paper Sales in the North
Area? (Make a note of your answer).

5. Display the Average sales of Timber in the South Area for all
salespeople. Format the figures to whole numbers.

6. Change the calculation back to a Sum of all sales and format to Currency.

7. Create a PivotChart as shown below: Note that this is showing the


number of Units Sold, not the value.

Units Sold 2011/2012


1400

1200

1000
Sum of Units Sold (tons)

800
Paint
600 Paper
Timber
400

200

0
November December January February 21
Month

You might also like