Excel Pivottables Made Easy
Excel Pivottables Made Easy
EXCEL PIVOTTABLES
MADE EASY
A STEP-BY-STEP GUIDE TO
PIVOTTABLES IN EXCEL
2
Excel PivotTables Made Easy: A Step-by-Step Guide to PivotTables in Excel
1st edition
© 2021 Alan Murray & bookboon.com
ISBN 978-87-403-3770-9
3
EXCEL PIVOTTABLES MADE EASY Contents
CONTENTS
About the Author 5
Introduction 7
2 PivotTable Calculations 30
2.1 Change PivotTable Function 30
2.2 Group PivotTable Data 33
2.3 Show Values As Percentages, Running Totals and Rankings 39
5 Using PivotCharts 71
5.1 Insert a PivotChart 71
5.2 Modify the PivotChart 73
4
EXCEL PIVOTTABLES MADE EASY About the Author
I am an Excel and Power BI trainer. I have been helping individuals and companies get the
most from Excel for over 20 years. I love helping users succeed with Excel.
I set up my Computergaga blog in 2009 as a resource for Microsoft Excel tips and tutorials.
It is a great reference point for Excel learners and myself, when I forget things.
My blog gives me the chance to reach more people than I can physically. I am honoured
to have helped millions of people reach their Excel goals.
The Computergaga YouTube channel was set up in 2010 to provide free Excel tips and
tutorials. It has over 550 videos and has had more than 30 million views.
In 2020, I was awarded MVP by Microsoft in the Office Apps & Services category.
Microsoft Most Valued Professionals are “technology experts who passionately share their
knowledge with the community” and the award is given by Microsoft in recognition of
“exceptional community leadership”.
I also organise the monthly London Excel Meetups. These meetups are FREE and provide
a relaxed and enjoyable environment to connect with other Excel users. Each meetup has
presentations from Excel experts.
5
EXCEL PIVOTTABLES MADE EASY About the Author
Come along and boost your Excel skills at one of our events. I would love to see you there.
6
EXCEL PIVOTTABLES MADE EASY Introduction
INTRODUCTION
Welcome, to your journey to mastering PivotTables in Excel.
PivotTables are one of the most popular and powerful tools in Excel. It is a common
request from learners on my training sessions. “I need to know how to use PivotTables” is
an often-muttered phrase.
Many people I train have seen a PivotTable on spreadsheets at work but have never created
one themselves. They believe it is an advanced feature beyond their capabilities. In this
book, you will see that is fiction. And that PivotTables are easy.
This book is a complete guide to using PivotTables. It will take you step-by-step from creating
your first PivotTable to using the more advanced PivotTable features. It will certainly be
an enjoyable journey.
Notation
Let’s be clear on some of the notation you can expect in this book.
The name of a button, keystrokes, or tab of the Ribbon, or a window that we click will be
in bold text. For example, click the Insert tab of the Ribbon.
Titles and other text that you see on screen and are referenced in the book, will be shown
in italics. For example, in the Create PivotTable window.
Names of files, sheet tabs, tables or fields will be shown with square brackets. For example,
move the [Product] field.
Excel Versions
The version of Excel that I am using in the book is Microsoft 365.
You may notice small differences between some of the images in the book and what you see
in your Excel. Please bear in mind that Excel is constantly evolving, and this can produce
change to the publication of this book.
7
EXCEL PIVOTTABLES MADE EASY Introduction
8
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
1 GETTING STARTED
WITH PIVOTTABLES
File: pivottables.xlsx (used for chapters 1-6)
In this chapter, we will create our first PivotTable, and cover the essential skills that you
need to know to work with PivotTables in Excel.
The data we will be working with throughout the book, is a list of sales data. It includes
the order date, product name, product category, store where the item was sold, sales total
and more.
Figure 1 shows a snapshot of this sample data. It is 9 columns wide and 1,972 rows in height.
Figure 1
This is perfect to get to grips with analysing data with PivotTables in Excel.
9
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 2
3. In the Create PivotTable window, the range is automatically detected (Figure 3).
Figure 3
10
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
If the range is incorrect, you can click in the Table/Range box and select the range you
want to use.
To place it on an existing worksheet; click Existing worksheet, click in the Location box, and
select the sheet and then the cell that you want to place the PivotTable (Figure 4).
Figure 4
5. Click Ok.
The PivotTable is empty, so will not look very impressive, yet. The PivotTables Fields pane
is also displayed. This will be used to build our PivotTable shortly (Figure 5).
11
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 5
There are two tabs on the Ribbon, PivotTable Analyze and Design (Figure 6).
Figure 6
We will explore many of the functionality of these tabs during the book.
12
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
There are a few reasons for this. The main reason is that by using a table, the source is
dynamic. When new rows or columns are added to a table, it automatically expands. This
ensures that they are included in the PivotTable reports.
If you use a range for your PivotTable source, you may need to edit the data source manually,
when new data is added. This can be done by clicking PivotTable Analyze > Change Data
Source (Figure 7)
Figure 7
The last chapter of this book explores creating PivotTables from the data model in Excel.
This also requires the use of tables for your source.
Let’s have a quick run through how to format a range as a table, before we insert a PivotTable.
Figure 8
13
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
3. In the Create Table window (Figure 9), the data range is automatically detected.
Check this is correct and change if necessary.
The My table has headers box is checked. We do have headers in the top row, so this is
good. Click Ok.
Figure 9
The range is converted to a table. The default style is applied (probably blue shaded banded
rows). The filter tool is also enabled on the header row.
You can easily change or create your own table style. I like to remove the style personally,
so will do that in this example.
14
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
4. Click Table Design and then the More arrow button to expand the table styles
gallery (Figure 10). Click Clear at the bottom of the gallery.
Figure 10
The next important step is to name the table. This makes it easy to reference from formulas,
or in our case, PivotTables.
5. Click the Table Design tab of the Ribbon. Change the name in the Table name
box (Figure 11). In this example, it is named [Orders].
Figure 11
There is much more to tables in Excel. They are a fantastic feature. But let’s get on and
create our PivotTable.
15
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
PivotTables love tabular data. They need column headers in the first row and do not want
merged cells. They therefore work effortlessly with data formatted as a table and prefer it.
Figure 12
Figure 13
16
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
The PivotTable is inserted, and the PivotTable Fields pane appears as shown in Figure 5.
Now we know how to insert a PivotTable from either a range or a table, we need to look
at how to build a PivotTable.
All the columns from the table/range are listed and four areas are shown underneath
(Figure 14). The areas are Filters, Columns, Rows and Values. To build the PivotTable; drag
the fields into the required areas.
Figure 14
Note: You can check the boxes next to the field names, but
this provides less control than dragging them.
17
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Drag the [Product] field into the Rows area and the [Total] field into the Values area
(Figure 15).
Figure 15
The PivotTable in Figure 16 is created. Your first PivotTable, nice and simple. It shows the
total sales for each product.
Figure 16
18
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
The Rows and Columns areas are for the labels of your PivotTable. The Values area is where
the calculation of your values occurs. The [Total] field has been summed in this PivotTable.
Note: When you drag a numeric value into the Values area,
the sum calculation is performed by default. If you drag, a
text value into Values, a count is performed.
By default, the values are ordered A-Z by the label, which in this instance is the product.
And the number formatting has an inconsistent number of decimal places.
We will look at changing the order, the calculation, and the number formatting later. For
now, let’s continue arranging the PivotTable fields.
Drag the [Product Category] field into the Rows area. Position it before the [Product] field
(Figure 17).
Figure 17
The product sales are now grouped by their category (Figure 18).
19
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 18
You can use multiple fields in all the PivotTable areas – Filters, Columns, Rows and Values.
In addition to the Rows area, is the Columns area. Drag the [Store] field into the Columns
area (Figure 19).
20
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 19
The stores sales values are now shown in columns with the product values across the rows
(Figure 20). This type of matrix or crosstab report is very popular.
Figure 20
To remove a field, click the list arrow on the field name and click Remove Field (Figure
21). You can also click and drag the field out of the area to remove it.
21
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 21
Right click one of the values you want to format and click Number Format (Figure 22).
Figure 22
22
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
By selecting Number Format, it will format all the values in the [Sum of Total] field. If you
select Format Cells or use the format options available on the mini toolbar, it only formats
the selected cells.
This ensures that all the values are formatted consistently. Notice, we do not need to select
all the cells. Just right clicking on one value is enough.
The Format Cells window opens. These values represent money, so I have selected the
Accounting number format. I have also opted for the British Pound symbol and 0 decimal
places (Figure 23).
Figure 23
The number formatting is applied to all the values in that field (Figure 24). We can format
other fields in the PivotTable using the same approach.
23
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 24
We will cover further PivotTable formatting options such as styles and layouts later in this
book.
Firstly, by the [Product] sales values in largest to smallest order, and then by [Product
Category] values in largest to smallest order.
Right click one of the [Product] sales values (Figure 25 shows right clicking on the Hot
Chocolate sales). Point to Sort and click Sort Largest to Smallest.
24
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 25
The [Product] values are ordered largest to smallest in each category (Figure 26). However,
the [Product Category] values remain in A to Z order (Beverages, Cakes & Pastries, Food).
25
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 26
The same technique can be applied to the [Product Category] values to order them largest
to smallest.
Right click one of the [Product Category] values (Beverages in this example), point to Sort
and click Sort Largest to Smallest (Figure 27).
Figure 27
26
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
The [Product Category] values are now ordered largest to smallest in addition to the
[Product] values (Figure 28).
Figure 28
To sort the [Product Category] values in A to Z order again, right click a [Product Category]
name, point to Sort and click Sort A to Z (Figure 29).
27
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 29
To refresh a PivotTable; right click the PivotTable and click Refresh (Figure 30).
28
EXCEL PIVOTTABLES MADE EASY Getting Started with PivotTables
Figure 30
Or you can refresh a PivotTable using the Refresh button on either the Data or PivotTable
Analyze tabs of the Ribbon.
Using the Ribbon, we can refresh all PivotTables at one time by clicking the Refresh list
arrow and Refresh All (Figure 31).
Figure 31
29
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
2 PIVOTTABLE CALCULATIONS
In this chapter, we will explore how to change PivotTable calculations and additional ways
that you can present values. We will also look at grouping values in a PivotTable.
Let’s add a new column to our existing PivotTable to show the count of sales in addition
to the sum of total field that we currently have.
1. Click and drag the [Total] field into the Values area so that we have it there
twice (Figure 32).
Figure 32
2. Right click one of the [Sum of Total2] values, point to Summarize Values By
and click Count (Figure 33).
30
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 33
We now have both the total sales and the count of sales for product category and each
individual product in one PivotTable (Figure 34).
Figure 34
31
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
The field headers [Row Labels], [Sum of Total] and [Count of Total2] could be improved.
Click and type to replace each header (Figure 35).
Figure 35
There are eleven PivotTable Functions in total. Seven are accessible from the shortcut menu.
To view more, click More Options (Figure 36).
Figure 36
In the Value Field Settings window, you can select the function to use and click Ok
(Figure 37).
32
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 37
The typical example is to group date and time fields into years, quarters, month, hours or
whatever you need. But grouping other numeric fields such as performance scores, ages and
prices can also be useful for analytics.
Our [Orders] table contains a date field named [Order Date]. This is the date of each order.
We will use it in the PivotTable to group the sales by year, quarter, and month. We are not
interested in the performance of any specific date in our report.
33
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
1. If you are following from the previous example, remove the [No of Sales] and
[Product] fields from the PivotTable.
2. Click and drag the [Order Date] field into the Rows area before the [Product
Category] field. It automatically groups into [Months] and [Order Date]
(Figure 38).
Figure 38
3. This not the grouping that we wanted. Right-click on one of the [Order Date]
cells and click Group (Figure 39).
34
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 39
4. In the Grouping window, click Days to remove that group and click Quarters
and Years (Figure 40).
Figure 40
35
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
You can see in the PivotTable Fields pane, that the original [Order Date] field maintains
that name, even though it is currently grouped as month. The [Years] and [Quarters] fields
were created due to the grouping.
Figure 41
5. Now that we have those groupings, remove the [Years] field and click and drag
the [Quarters] and [Order Date] fields into the Columns area (Figure 42).
Figure 42
36
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
The Columns area is fantastic for viewing values over time. Figure 43 shows the completed
PivotTable.
This PivotTable report shows the product category sales month-on-month with quarterly
subtotals.
Figure 43
You can group any numeric field with PivotTables, so let’s see another example. In this
example, we will create a report that groups orders by the [Total] field and counts the
number of orders in that range.
1. If you are following from the previous example, remove the [Quarters] and
[Order Date] fields from the PivotTable.
2. Click and drag the [Total] field into the Rows area and position it before the
[Product Category] field (Figure 44).
3. Change the calculation of the [Total] field in Values from Sum to Count.
4. Change the number formatting of the [Total field] to Number, with 0 Decimal
places and check the box for Use 1000 separator (,).
The PivotTable does not look very good at all at the moment (Figure 44). The [Total] field
in Rows needs grouping. We will group it by 100 e.g., 0-99, 100-199, 200-299, 300-399.
37
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 44
5. Right-click a cell that contains the [Total] field label and click Group.
6. Change the Starting at value to 0 and the Ending at value to 40The By value
should be set to 100 (Figure 45). Click Ok.
Figure 45
Figure 46 shows the finished PivotTable report. The total count of orders is shown for each
group and each product category within those groups.
You can see that there are no Cakes & Pastries orders for £200 or more.
38
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 46
Let’s see the different options available and demonstrate the use of percentages, running
totals and rankings.
In the first example, we will create a PivotTable report that shows the sales for each product
category, and then another column to show the sales value as a percentage of the column
total.
39
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
1. Start with a PivotTable that has the [Product Category] field in Rows and the
[Total] field in Values. The [Total] field should be summarising the values with
Sum.
2. Add the [Total] field to the Values area a second time.
3. Right-click one of the values in the second values column, select Show Values
As and then click % of Column Total (Figure 47).
Figure 47
4. Enter a meaningful title for the column. “% of Total” has been used in this
example (Figure 48).
40
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
Figure 48
1. Set up the PivotTable as shown in Figure 49. The [Total] field has been added
to Values twice. Ensure that they are both set to Sum. The [Order Date] field is
in Rows (remember, this field shows months).
Figure 49
2. Right-click a value in the second [Total] values column, select Show Values As
and then click Running Total In.
41
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
3. You are asked for the field to use as the base for the running total (Figure 50).
[Order Date] is the only option as it is the only field that we have in the Rows
area of our PivotTable. If we had more than one field in Rows, we would need
to specify which one for the running total.
Figure 50
4. Change the number formatting of the values to number, 0 Decimal places and
with the thousand separator.
5. Enter a meaningful title for the column, such as “Running Total”.
Figure 51
The final example of the Show Values As options will be to creating a ranking.
Previously in this book we have demonstrated how to sort the values of a PivotTable. We
can sort values to rank them in order by sales value or some other criteria. However, you
can only sort by one field from the Values area.
42
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
In this example, we will create a PivotTable report to show the sales from each store by
quarter. We will then create a rank field for the store performance each quarter.
1. Set up the PivotTable as shown in Figure 52 Check that both [Total] fields are
set to Sum. The [Quarters] field is in Columns and [Store] field in Rows.
Figure 52
2. Right-click one of the values in the second [Total] columns, select Show Values
As and click Rank Largest to Smallest.
3. Select Store for the Base Field (there is also the option to rank by quarter).
Click Ok.
Figure 53
43
EXCEL PIVOTTABLES MADE EASY PivotTable Calculations
4. The PivotTable just needs some of the column widths to be resized and the
titles improved. Figure 54 shows the finished PivotTable report. I have renamed
the columns to “Total Sales” and “Rank”.
Figure 54
44
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Many of these settings can be changed. Let’s explore some of the design options available
for our PivotTables.
Figure 55 shows the subtotal for each store above the group (product category totals).
Figure 55
I like this! But it is easy to display the subtotals below the values if you prefer, or even to
not show them at all.
Click Design > Subtotals to see the options available. Click Show all Subtotals at Bottom
of Group to show them below the values (Figure 56).
45
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 56
Figure 57 shows the PivotTable with the store subtotals below the group.
Figure 57
Click Design > Grand Totals to show or hide grand totals, and if shown, whether you
want grand totals for rows only, columns only or both row and column labels (Figure 58).
46
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 58
The Tabular form is quite popular, so in this example we will switch a PivotTable from
Compact form to Tabular form. We will also see some supporting options.
The PivotTable we are working with has the [Store] and [Product Category] fields in Rows
and the [Total] field in Values to Sum the values (Figure 59).
Figure 59
47
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 60
The store and product category fields are separated into different columns and the subtotals
are shown below the values.
Figure 61
This layout is very nice. There are blank cells under the store names. To fill these blanks;
click Design > Report Layout > Repeat All Item Labels.
48
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 62 shows the PivotTable in Tabular form with the item labels repeated. The subtotals
have also been hidden.
Figure 62
Click Design > Blank Rows > Insert Blank Line after Each Item to separate each store
with a blank row (Figure 63).
Figure 63
49
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 64
It is useful to be aware of the different layouts and settings. PivotTables can be used for
more than just reporting.
Figure 65 shows a PivotTable with the default PivotTable style applied. The PivotTable is
in the Compact Form layout.
50
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 65
To change the PivotTable style; click Design and then the More button in the corner of
the PivotTable Styles gallery (Figure 66).
Figure 66
The gallery expands showing plenty of styles to choose from. The styles are grouped into
light, medium and dark categories.
Figure 67 shows the Dark Grey, Pivot Style Dark 12 style applied to the PivotTable.
Figure 67
51
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
If you are not happy with the pre-set styles available in the gallery, you can create your
own. This feature is useful if you need to follow the formatting guidelines established within
your organisation.
1. Click Design, then the More button in the corner of the PivotTable Styles
gallery.
2. Click New PivotTable Style at the bottom of the gallery list (Figure 68).
Figure 68
Figure 69 shows the Row Subheading 1 element formatted with a green fill colour. The
elements you have formatted turn bold and may be shown in the preview to the right.
52
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
Figure 69
It is not that clear what the different elements of the PivotTable are. You may need to make
a change and look at the impact it has made to get a better idea.
To edit an existing PivotTable style, right-click on it in the gallery and click Modify
(Figure 70).
Figure 70
53
EXCEL PIVOTTABLES MADE EASY PivotTable Styles and Other Design Settings
54
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Let’s take a look at the three different filters and how and when you would use them.
1. Set up the PivotTable as shown below. The [Product Category] and [Product]
fields are in the Rows area. The [Total] field is in Values set to Sum.
The PivotTable is sorted in descending order by the sales values of both the [Product
Category] and [Product].
Figure 71
2. Click and drag the [Store] and [Order Date] fields into the Filters area (Figure
72). The report filters appear above the PivotTable by default (they can be
moved).
55
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 72
Figure 73 shows the PivotTable filtered by the Olympia store and the month of May. The
PivotTable maintains the sort order of descending by sales value.
PivotTables make is very fast and easy to drill to this level of detail and produce a report.
Figure 73
56
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
1. Create a PivotTable with the [Product] field in Rows and the [Total] field in
Values set to Sum.
2. Sort the PivotTable by the sales value largest to smallest.
3. Click on the field filter in the Row Labels cell, select Value Filters and click
Top 10 (Figure 74).
Figure 74
57
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
4. Although the option is named Top 10, you can filter for the bottom 10, or top
5 items, top 10 percent, and other variations. I love using this filter.
For this example, we will use the top 10 items and click Ok (Figure 75).
Figure 75
The completed PivotTable shows the top 10 products only (Figure 76). The grand total
also only sums these top 10 values. Remember, the grand total can be removed if you do
not want it.
Figure 76
58
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
To demonstrate the use of Slicers, we need a few PivotTables to work from. Create the
three PivotTables shown in Figure 77.
These are PivotTables we have created together during the course of the book. Copy and
paste the PivotTables to create duplicates – it is the easiest and most efficient way.
• The sum of [Total] and running total month-on-month. The [Order Date] field
is used in Rows.
• Sum of [Total] by [Product]. Sorted largest to smallest and filtered to show the
top 10 products only.
• Sum of [Total] by [Reps]. Sorted largest to smallest.
Figure 77
Give each PivotTable a meaningful name so that it is easy to identify them. To do this,
click a cell in the PivotTable, click PivotTable Analyze and enter a name in the PivotTable
Name box (Figure 78).
59
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 78
We will insert two Slicers, one for the [Product Category] field and another for the [Order
Date] field (currently grouped as month).
Note: You can click inside any PivotTable that you want the
Slicer to work with, it does not need to be the first one.
60
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 79
3. Check the boxes for the [Order Date] and [Product Category] fields (Figure
80). Click Ok.
Figure 80
4. The Slicers are dropped into the middle of the sheet. Move them to a suitable
location.
At the moment, the Slicers are connected to the first PivotTable only, because that was the
active PivotTable when they were inserted.
61
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 81 shows the first PivotTable being filtered when Food is selected in the [Product
Category] Slicer.
Figure 81
Note: You can select more than one option in the Slicer by
holding Ctrl as you click. Click the red X in the top right
corner to clear the filter.
A great thing about Slicers is that you can choose which PivotTables are filtered by a Slicer
and which ones are not.
In this example, we want the [Product Category] Slicer to filter all three PivotTables. However,
we only want the [Order Date] Slicer to filter the top 10 products and sales rep PivotTables.
Figure 82 shows the [Order Date] Slicer filtering the month-on-month PivotTable. This
makes no sense, and we should disable that connection.
62
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 82
1. Select the [Order Date] Slicer (you see the resize circles around the border
when selected).
2. Click Slicer > Report Connections.
Figure 83
63
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
3. Check the boxes for the Top 10 Products and Sales Reps PivotTables and remove
the check for the Monthly PivotTable (Figure 84).
Figure 84
4. Now, select the [Product Category] Slicer and edit the report connections so
that it is connected to the Monthly, Top 10 Products and Sales Reps PivotTables.
Figure 85 shows both Slicers being applied. The [Order Date] Slicer no longer filters the
Monthly PivotTable, but it does filter the Top 10 Products and Sales Reps PivotTables.
Figure 85
There are a few useful settings to customise the way your Slicers look and function. Let’s
look at a few changes we can make to our Slicers.
64
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
We will start by changing the Slicer caption. The [Order Date] Slicer has been grouped
into months, so the caption Order Date does not really reflect the data.
Figure 86
Now, one of my favourite options with Slicers is changing the number of columns. Slicers
are always presented as a vertical list, but let’s change that.
1. Select the [Order Date] Slicer (it is still named [Order Date], only the caption
is Month).
2. Click Slicer and change the number in the Columns box to 12 (Figure 87).
Figure 87
65
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
3. Insert three more rows above the PivotTables. Resize and move the [Order
Date] Slicer above the Top 10 Products and Sales Reps PivotTables as shown in
Figure 88.
Figure 88
The final change I want to make to the [Order Date] Slicer is to hide the items with no
data. I love this setting as it stops the Slicer showing you items that will not return results.
In the [Order Date] Slicer, there are items on the end showing the range of our data. We
do not need to see these items.
66
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 89
The items on the end of the Slicer are removed (Figure 90).
Figure 90
An alternative to the [Order Date] Slicer we have been working with, is to use the Timeline.
This is a Slicer specifically built to filter time-based data.
67
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 91
3. Only the [Order Date] field is shown in the Insert Timelines window because
that is the only date field in our dataset. Check the box for the [Order Date]
field and click Ok (Figure 92).
Figure 92
4. Resize and position the Timeline above the Top 10 Products and Sales Reps
PivotTables.
5. Select the Timeline, click Timeline > Report Connections (Figure 93) and
connect it to the Top 10 Products and Sales Reps PivotTables. Disconnect it
from the Monthly PivotTable.
68
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Figure 93
The Timeline Slicer can be used by clicking a rectangle that represents a month, dragging
a selecting rectangle or resizing it. Figure 94 shows the PivotTables filtered for the date
range of April to September.
Figure 94
69
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers
Now with this data, we only really want to work with the months. There is a very useful
time level selector (shown in Figure 95), but in this example we do not need it as we do
not plan on changing the level.
To hide the time level and the selection label which are in line with each other; select
the Timeline, click Timeline, and uncheck the Selection Label and Time Level boxes
(Figure 95). This reduces some of the clutter in the Timeline.
Figure 95
Figure 96 shows the Timeline with the selection label and time level removed.
Figure 96
70
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
5 USING PIVOTCHARTS
Charts are often a more effective way of visualising results than a table.
A chart created from a PivotTable is known as a PivotChart. You can organise the fields of
a PivotChart in the same way that do a PivotTable.
Not all chart types can be created from a PivotTable. For example, you cannot create Scatter,
Treemap, Stock or Map charts from a PivotTable.
Despite some limitations with PivotCharts compared to the standard charts you find on the
Insert tab. You should always use the PivotCharts, because if you insert a standard chart,
it does not update with the PivotTable effectively.
Charts are very powerful and have many options. In this chapter, we will cover how to
insert a PivotChart and make some useful modifications.
Figure 97
71
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
The Insert Chart window lists the charts for you to select from. The chart types are in a
column down the left of the window, and along the top are the sub-types of that chart.
3. Select Column on the left and then Clustered Column on the sub-type row
(Figure 98).
Figure 98
4. Position and resize the chart under the Top 10 Products and Sales Reps
PivotTables (Figure 99).
This chart is connected to the Top 10 Products PivotTable. Any changes to the PivotTable
will in turn affect the PivotChart, and vice-versa.
The chart is currently filtered by both Slicers. The Timeline is set to filter for the month
range of April to October, and Cakes & Pastries is selected from the [Product Category] Slicer.
72
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
Figure 99
We will start by changing the chart title to something meaningful (In Figure 99, you can
see that it currently says “Total”).
73
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
Figure 100 shows the chart with the new chart title.
Figure 100
This chart contains a few elements that I do not believe are necessary. They are extra noise
that do not contribute to this visual. These include the Legend, Primary Vertical Axis,
Gridlines, and the Field Buttons.
To remove the chart elements; click Design > Add Chart Element and remove the element
you no longer want. Figure 101 shows the Primary Vertical Axis being removed.
Figure 101
74
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
These steps work for the Legend, Primary Vertical Axis, and the Gridlines, but removing the
Field Buttons requires a different approach.
Field buttons can be useful because they can be used to filter your PivotChart directly.
However, they are not required in this scenario. The Slicers and the field filter (top ten
products) that we set previously are used for the filtering.
To remove the Field Buttons; click PivotChart Analyze > Field Buttons (Figure 102).
Figure 102
Note: You can use the list arrow and remove specific Field
Buttons only such as the Axis Field Buttons.
Figure 103 shows the PivotChart with the unnecessary chart elements removed.
Figure 103
75
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
With the value axis removed, we do not know the values for each column. Let’s add data
labels to the chart to show their values.
In the previous example we removed chart elements using the Add Chart Elements button
on the Design tab, but there is also one to the right of the chart.
Figure 104
The default colour with the Office theme is blue. Let’s change the colour of the columns
in our chart.
76
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
Figure 105
When you click different item in our Slicers e.g., Food or Beverages, the width of the column
chart adjusts.
This is because the different products have different length names. For example, Chocolate
Chip Muffin is a much longer name than Tea. The PivotTable that the column chart is
connected to automatically adjusts (autofits) its column widths to accommodate the content.
77
EXCEL PIVOTTABLES MADE EASY Using PivotCharts
Figure 106
78
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
Let’s now explore a few more options that are often of interest to users. And then look at
changing the default settings, so that we do not have to make these changes every time we
create a new PivotTable.
1. Click a cell in the PivotTable that you want to change the options for.
2. Click PivotTable Analyze > Options (Figure 107).
Figure 107
Figure 108 shows the Layout & Format tab of the PivotTable Options window. Two commonly
changed settings on this tab are;
• For empty cells show – you can enter an alternative value for a blank cell. 0 is
often used.
• Autofit column widths on update – this setting stops the PivotTable column
widths adjusting to fit the columns content, often as a result of a filter. We saw
this setting in the previous chapter to stop the PivotChart width changing.
79
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
Figure 108
Figure 109 shows the Totals & Filters tab of the PivotTable Options window. Interesting
options on this tab include;
• Grand Totals – show and hide the grand totals for the rows and columns of a
PivotTable. In an earlier chapter, we saw that you can also change this from the
Design tab of the Ribbon.
• Use Custom Lists when sorting – Custom Lists are used by Excel to effectively sort
days of the week and names of months. It is possible to also create your own
custom lists in Excel.
80
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
This option is switched on by default. However, occasionally it can cause a problem e.g., if
you have a colleague named Jan. On these occasions the setting can be switched off.
Figure 109
Figure 110 shows the Data tab of the PivotTable Options window. Common settings on
this tab include;
• Enable show details – If you double click on a value in the PivotTable, a new
worksheet is created with the table of data used for that value. This is a cool
feature and is enabled by default. If you do not want it, uncheck the Enable
show details box.
• Refresh data when opening the file – This is possibly the most used setting in the
entire PivotTable Options window. PivotTables need to be manually refreshed
to update their data. This setting ensures that PivotTables are automatically
refreshed when the workbook is opened.
81
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
Figure 110
You may require one PivotTable to have the compact layout and another to be in tabular
layout. You may want grand totals in one, but not in another.
It is possible to edit the default PivotTable options though too. This is fantastic! So, you
can set up your PivotTables in the way that you generally like to use them. You can still
change settings on a per PivotTable basis when you want something different.
82
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
Figure 111
In the Edit default Layout window, you can see many of the settings discussed through the
book (Figure 112).
• Specify if and where you want subtotals and Grand Totals to be shown.
• Set the default Report Layout and whether you want to Repeat All Item Labels
and Insert Blank Line after Each Item.
• There is a PivotTable Options button to set defaults such as Refresh data when
opening the file and For empty cells show, that were discussed previously.
• You can also import the settings from an existing PivotTable.
83
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You
Figure 112
84
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
This chapter introduces working with the data model, otherwise known as Power Pivot, in
Excel.
In this chapter we will create a PivotTable from multiple different tables. We will do this
by creating relationships between the tables, this stores them in the data model, and then
inserting a PivotTable from the data model.
Note: There is much more you can do with the Power Pivot
than what we will cover in this chapter, including using its
powerful formula language known as DAX. Learning Power
Pivot requires its own book.
• Sales
• Products
• Reps
• Stores
Figure 113 shows the Sales table. In this table, we have the transactional data. There are
columns for the Order ID, Order Date and Total.
There are also columns that we will be using to connect to the other tables. These are
Product, Store and SP ID. These columns can also be found in the associated tables and are
the key fields that will be used to link them together.
85
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 113
Figure 114 is a snapshot of the Products table. The Product ID column will be used to
link it to the Sales tables Product column. There are also columns for the product name,
category, and price.
Figure 114
Figure 115 shows the Reps table. The ID field is the key field and will be linked to SP ID
field of the Sales table.
86
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 115
And finally, Figure 116 shows the Stores table. The Store ID field is the key field.
Figure 116
The PivotTable can then be created from the Sales table. But you do not need to do this.
We will create relationships between the four tables, instead of the lookup formulas. And
then create a PivotTable from the multiple tables.
87
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 117
Figure 118
3. Figure 119 shows all fields of the Create Relationship window completed to
establish a relationship between the Sales and Products tables.
88
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 119
The relationship is created and shown in the Manage Relationships window (Figure 120).
The two tables are also loaded to the data model.
Figure 120
89
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
4. Click New and create the relationship between the Sales table and the Reps
table.
As you select the table, you can see that the Sales and Products tables have been loaded to
the data model (Figure 121). The other two tables are still worksheet tables.
Figure 121
5. Complete the Create Relationship window as shown in Figure 122 Click Ok.
Figure 122
6. Click New and create the final relationship between the Sales and Stores tables.
7. Complete the Create Relationship window as shown in Figure 123 Click Ok.
90
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 123
All three table relationships have now been created (Figure 124). Click Close.
Figure 124
91
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 125
The PivotTable is inserted onto a new worksheet. The PivotTable Fields pane shows all four
tables (Figure 126). The arrow to the left of the table name is used to expand the table
and see its fields.
Figure 126
92
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
When you have multiple tables, it gets very busy in the fields pane. Because of this, I like
to change the layout so that the areas (Filter, Columns, Rows and Values) are shown to the
right of the fields, instead of below.
3. In the PivotTable Fields pane, click the Tools button and click Fields Section
and Areas Section Side-By-Side (Figure 127).
Figure 127
93
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 128
5. Change the number format to Number, 0 decimal places and with a thousand
separator.
94
EXCEL PIVOTTABLES MADE EASY Working with the Data Model – An Introduction
Figure 129
This chapter was an introduction to using the data model. This feature has much more
functionality that can be explored.
95