Pivot Tables
Pivot Tables
A Pivot table allows you to "interactively" aggregate your data and is a great
way to generate a dynamic summary report.
The term pivot refers to being able to change the position of the fields and to
being able to transpose the rows and columns of your table.
The more data you have to analyse then the more appropriate it is to use a
pivot table.
Pivot Tables are designed for dynamic viewing of database data (either
contained within Excel or from an external source).
Pivot Tables are always linked to the data they are derived from.
When a Pivot table is created Excel builds a special memory cache
containing your data. This allows you to change and recalculate your data.
The data you will want to analyse will normally be numerical values,
although it is possible to also use text values as well.
Looking at the Excel list it is hard to identify how much is being spent a
month on each division.
The pivot table below summarises this Excel list and makes it much easier to
understand.
Pivot Charts
You can create charts that are directly linked to your pivot table results.
It is even possible to change the data layout by adjusting the chart.
Potential Problems
If someone adds or deletes a column in the original source data, the
pivottable cannot be refreshed and displays an error.
You can use a pivot table to link to a range of data on another sheet and
display it in a different order.
A pivot table is extremely useful when you have lots of changing rows, or
blank rows , when the number of rows changes frequently.
AutoShow
You can use the AutoShow feature to display only a certain number of items
in a field based on values in the data area of your table.
Choose the field in the pivot table and select (PivotTable > Field Settings)
Select Advanced.
Empty Cells and Cells containing Errors
By default cells that do not contain any numbers in the data area are left
blank.
It is possible to display a value or a text entry in any empty cells.
To switch from one summary function to another select an item in the data
area of your pivot table, click the field settings button and then choose from
the list that appears in the Pivot Table field dialog box.
Grouping on a particular field can be very useful if you want summarize data
over a range of values -- Right-click the field label and choose Group and
Outline | Group...
Blank rows in the data set will prevent you from using Grouping in your Pivot
Table
Calculated Fields
This is a new column
It is possible to add additional fields to your pivot table which are actually
functions of existing fields.
You can create an additional field in your pivot table which can be based on
other fields in your pivot table.
You can use any of the standard Excel formula options on this dialog box.
It includes all the normal mathematical operators including all the worksheet
functions.
The arguments used in your formula must match the field names in your
pivot table.
You cannot use any cell references or range names in your formulas.
Each calculated field that you add displays as an additional Data Field.
These will also automatically be added to the Field List Pane and the Layout
dialog box.
Calculated Items
This is a new row
You can create new items that can appear in your fields that are not part of
the original source data.
A calculated field contains user-created formula to determine the value of
the item in a particular field.
You create a calculated item by adding a new item to a field and then
defining a formula that calculates the individual values for the item.
List Formulas
Options > Formulas > List Formulas
Summary Functions
Field Calculations
If the data area contains numerical values then the SUM() function is used by
default
If the data area contains non numerical values then the COUNT() function is
used.
What are the options ?
You can specify which fields to include and the type of calculations used on
those fields.
For each combination of values in the row and column fields, the data field
takes on a different value and this value appears in the data area.
Default Calculations
It is possible to use other function in order to summarise your data.
There are actually a choice of eleven different aggregate functions that can
be used in your pivot table.
SUM This is the default function used when the data area contains numeric
numbers in a list or cell range.
COUNT This is the default function used when the data area contains non num
numeric values in a list or array of numbers.
COUNTA Count Nums The number of non blank cells in a list or cell range.
AVERAGE The arithmetic mean of a list or array of numbers.
MAX The largest value in a list or array of numbers.
MIN The smallest value in a list or array of numbers.
PRODUCT The product of all the numbers in a list or cell range.
STDDEV The standard deviation based on a sample.
STDDEVP The standard deviation based on an entire population.
VAR The compound variance based on a sample.
VARP The variance based on an entire population.
When you change the function, the Data area will reflect the changes
automatically.
It is possible to customise the selected function by adding some calculation
options on the pivot table field dialog box.
In addition to the eleven functions that are provide by default you can also
create your own custom calculations.
Custom Calculations
There are also a large number of custom calculations which you can use
including running totals and item percentages.
Some of these calculations require a field to use as well as the value for the
field.
To apply a custom calculation (PivotTable > Field Settings) "Options".
When you select a member of the Base Field, the corresponding items will
automatically be displayed in the Base Item.
Normal Default
Difference From Calculates the difference between two cells.
% of Calculates the percentage of a cell to a selected base value.
% Difference From Calculates the difference between two cell values.
Running Total in Calculates and displays the running total in each cell.
% of row Calculates the percentage of the cell value to the total row.
% of column Calculates the percentage of the cell value to the total column.
% of total Calculates the percentage of the value of the grand total.
Index Calculates the index value of the cell value.
Important
You also have the option of creating your own calculated fields and items.
Grouping
Grouping is a method that can be used to reduce the amount of data
displayed.
It is possible to combine items together from your row and column fields in
order to help organise and present your data.
A typical example is to group date fields in order to display month, quarter,
yearly aggregates when your data is daily.
As you divide a field into different groups new items will be created with the
corresponding group name.
After you have finished grouping your data you can remove the original field.
It is also possible to change the name displayed for a field or new group.
When you create a new group the subtotal will not appear automatically and
you will only see the totals for a group that is collapsed.
Can be used to display trends over a data period that is larger than that of
the actual data.
(PivotTable > Group and Show Detail) sub menu
For example if your data is daily but you want to display it monthly, then you
can group the data by months.
Adding a Group
Group -
Removing a Group
To remove a group select (Data > Group and Outline > Ungroup).
UnGroup -
Once a group is removed from a pivot table it no longer exists. If you want to
display the group again at a later date, then it must be re-created.
Important
You cannot group items that belong to different rows or columns.
It is possible to select and group items from the same field which do not
appear in adjacent rows or columns.
Pivot Table Drop-Down - This displays a full list of pivot table commands.
Format Report - Displays a dialog box allowing you to apply a built-in
combination of formats, called an autoformat.
Pivot Chart - Starts the Chart Wizard, which guides you through the steps
for creating an embedded chart on a worksheet or modifying an existing
chart.
Hide Detail - In a PivotTable or PivotChart report, hides displayed detail
data. On an outlined worksheet, hides the detail rows or columns of a
selected summary row or column. Hides the items in a group.
Show Detail - In a PivotTable report, displays detail data, if available, for
the selected cell. In a PivotChart report, displays detail data, if available, for
the selected field or item. On an outlined worksheet, displays the hidden
detail rows or columns of a selected summary row or column. Show all the
hidden items in the pivot table.
Refresh Detail - Updates the data in a PivotTable or a PivotChart report if
the source data has changed. This is disabled when the source data hasn't
changed.
Include Hidden Items in Totals - Toggles the hidden filtered items from
being included in the totals.
Always Display Items - Toggles the display of all the items.
Field Settings - Displays a dialog box allowing you to change settings, such
as subtotals, sort options, and layout options, for the selected field in the
PivotTable or PivotChart report.
Show Field List - Displays or hides the PivotTable or PivotChart field
buttons on the PivotTable toolbar. Also, in a PivotTable report, displays or
hides the layout diagram outlines and labels.
Important
It is not essential to keep the pivot table toolbar displayed as all the
commands can also be found on the pivot table shortcut menu when you
press the right mouse button.
Enable Selection - Turns PivotTable structured selection on or off. When
pressed in, you can select elements of the PivotTable report for formatting or
for refining calculated item formulas by pointing to the top or left side of a
field or item label until the pointer changes to a down arrow or a right arrow,
and then clicking.
Pivot Table Report - Starts the Pivot Table and Pivot Chart Wizard, which guides y
modifying a PivotTable or PivotChart report.
There are three steps allowing you to change the type of report, the data to
use and the location of your pivot table.
The pivot table wizard will take you through the three stages.
Step 1 - Type of Report - Lets you choose where the data is coming from
either an Excel list or database, external source, consolidation of ranges or
even another pivot table.
Step 2 - Source Data - Lets you select the cells and define the range to use
for the source data. If the insertion point is anywhere within the Excel list or
database then the whole block of cells will be selected automatically.
Step 3 - Location - Lets you decide whether to display the pivot table
report on a new worksheet or on the existing worksheet
Step 3b - Layout - This is not a separate step in the Wizard as it can either
be done before or after the pivot table has been created. This lets you
determine the exact layout of the report by dragging the fields onto a pivot
table diagram.
Type of Report
Highlight any cell within the data and select (Data > PivotTable and
PivotChart Wizard).
Your data must contain column headings as these will be automatically used
for the pivot table fields.
Creating just a pivot table with an Excel list is the default option so press
Next.
Note that the graphics down the left hand side change to confirm your
selection.
Microsoft Excel list or database - You data table must have unique
column labels at the top of each column.
External data source - Includes Access databases and other Excel
workbooks.
Multiple consolidation ranges - Multiple ranges containing similar data.
Another PivotTable or PivotChart -
Source Data
If you are using an Excel list and you have selected a cell within the list
before invoking the wizard then the continuous range of cells will be
selected.
If you select a single cell for the source data before displaying the Wizard the
current region will be automatically selected. You can change this in step 3
of the Wizard ??
All the data should be highlighted so press Next.
Excel will automatically select the range of cells in the continuous range.
It is possible to change the source data range after the pivot table has been
created.
Holding down the Shift key and pressing on the lower right cell will extend
the data source to include that cell.
You can also insert rows into the data source and the data will automatically
be included the next time the pivot table is refreshed.
Location
Decide whether you want to insert the pivot table onto a new worksheet or
the existing worksheet.
Before clicking on the Finish button you can select Layout button to define
the table layout of your pivot table.
New worksheet - A new worksheet will be inserted before the active sheet
containing your pivot table report. This is the default.
Existing worksheet -
Layout - You can always changes these at any point after the pivot table has
been created.
Options - Displays the (PivotTable > Table Options) dialog box.
Layout
After you have completed the steps the pivot table field list will be displayed
to let you change how the table is organised.
Final PivotTable
The following pivot table summarising your data will be displayed.
Important
You should also enter a name for the pivot table, the default will be
PivotTable1, PivotTable2, etc
If you assign the named range "Database" to your cell range it will be
recognised automatically.
If possible it is always better to base a new pivot table on an existing one as
it will use the same memory cache for both tables.