0% found this document useful (0 votes)
43 views

Excel Pivottables Made Easy

Uploaded by

zoheb.steel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Excel Pivottables Made Easy

Uploaded by

zoheb.steel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

Alan Murray

Excel PivotTables Made Easy


A Step-by-Step Guide to PivotTables in Excel
ALAN MURRAY

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

1 Getting Started with PivotTables 9


1.1 Insert a PivotTable from a Range 9
1.2 Insert a PivotTable from a Table 13
1.3 Arranging PivotTable Fields 17
1.4 Number Formatting 22
1.5 Sort PivotTable Values 24
1.6 Refresh PivotTable Data 28

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

3 PivotTable Styles and Other Design Settings 45


3.1 Show and Hide PivotTable Totals 45
3.2 PivotTable Report Options 47
3.3 PivotTable Styles 50

4 Filter your PivotTables and Using Slicers 55


4.1 Report Filter 55
4.2 Field Filter 57
4.3 Using Slicers 58

5 Using PivotCharts 71
5.1 Insert a PivotChart 71
5.2 Modify the PivotChart 73

6 Customise your PivotTables to Work for You 79


6.1 PivotTable Options 79
6.2 Default PivotTable Layout Options 82

7 Working with the Data Model – An Introduction 85


7.1 Introduction to our Data 85
7.2 Create Relationships Between Tables 87
7.3 Create a PivotTable from the Data Model 91

4
EXCEL PIVOTTABLES MADE EASY About the Author

ABOUT THE AUTHOR

My name is Alan and I live in Suffolk in the UK.

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 am very proud to be part of this amazing community.

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.

Learn Excel at the Computergaga YouTube channel

Computergaga site and blog

Come and join us at the London Excel Meetup group

Connect with me on LinkedIn

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

Download the Files for Practise


You can download the Excel workbooks that I use throughout this book from the link
below. Follow along with me and practise the techniques.

Download the Excel PivotTables Made Easy files

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.

1.1 INSERT A PIVOTTABLE FROM A RANGE


Let’s insert our first PivotTable from this range of data onto a new worksheet.

1. Click on any cell within the range.


2. Click Insert > PivotTable (Figure 2).

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.

Note: It is a common mistake to select the entire columns


of a range when creating a PivotTable. This creates blank
values in your PivotTable and is bad practise.

4. By default, the PivotTable will be placed on a new worksheet.

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 inserted.

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

1.2 INSERT A PIVOTTABLE FROM A TABLE


It is important to know that you can create PivotTables from a range in Excel. However,
it is recommended to create PivotTables from a table.

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.

1.2.1 FORMAT A RANGE AS A TABLE

Let’s have a quick run through how to format a range as a table, before we insert a PivotTable.

1. Click on any cell in the range.


2. Click Insert > Table or press Ctrl + T (Figure 8).

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 table style is removed. This range is still formatted as a table.

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

1.2.2 SUMMARIZE WITH PIVOTTABLE

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.

1. Click on a cell in the table.


2. Click Table Design > Summarize with PivotTable (Figure 12).

Note: You could also click Insert > PivotTable.

Figure 12

3. In the Create PivotTable window, the [Orders] table is input automatically as


the source (Figure 13). Let’s keep the default destination of new worksheet.

Figure 13

Note: Steps to insert a PivotTable on an existing worksheet


are shown in chapter 1.1 Insert PivotTable from a Range.

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.

1.3 ARRANGING PIVOTTABLE FIELDS


Building PivotTables is easy with the PivotTable Fields pane.

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

This is a useful PivotTable, and so fast and simple to create.

You can use multiple fields in all the PivotTable areas – Filters, Columns, Rows and Values.

Note: If you click a cell on the worksheet outside the


PivotTable, the PivotTable Fields Pane disappears. Click a
cell within the PivotTable to bring it back.

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

Let’s now remove the [Store] field from the PivotTable.

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

1.4 NUMBER FORMATTING


Now, let’s format the values for better presentation.

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.

1.5 SORT PIVOTTABLE VALUES


It is simple to sort your PivotTables at any level of the report. We will look at sorting this
PivotTable by both levels.

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

You can see that sorting PivotTable data is very simple.

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

1.6 REFRESH PIVOTTABLE DATA


The PivotTable we have created is connected to the [Orders] table. Any changes to the data
in the [Orders] table can be updated in the PivotTable.

However, the PivotTable is not updated automatically. It needs to be refreshed to reflect


any changes in the data source.

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.

2.1 CHANGE PIVOTTABLE FUNCTION


As mentioned in the previous chapter, a PivotTable defaults to summing numeric values
and counting text values. However, this can easily be changed.

2.1.1 ADD ANOTHER CALCULATED COLUMN

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

2.1.2 FURTHER PIVOTTABLE FUNCTIONS

There are eleven PivotTable Functions in total. Seven are accessible from the shortcut menu.
To view more, click More Options (Figure 36).

Figure 36

Note: Distinct Count is only available for PivotTables created


from the data model, covered later in this book.

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

2.2 GROUP PIVOTTABLE DATA


With PivotTables, you can easily group any numeric field.

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.

2.2.1 GROUPING DATE FIELDS

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).

Note: Automatic grouping was introduced in Excel 201If


it does not automatically group for you, do not worry, we
will demonstrate how to group the field shortly.

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

The PivotTable is grouped by these three levels (Figure 41).

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.

Note: This dataset only contains one year of data (2019) so


the results for the [Years] group is currently useless. However,
I thought it beneficial to demonstrate to group by year as
it is commonly very useful.

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

2.2.2 GROUPING OTHER NUMERIC FIELDS

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

Note: The PivotTable groupings display as 0-100, 100-200


and so on. However, it is really 0-99, 100-199 and so on. If
there is an order for 100, it goes into the 100-200 group
only, and not the 0-100 group.

Figure 46

2.3 SHOW VALUES AS PERCENTAGES,


RUNNING TOTALS AND RANKINGS
There are many useful ways that you can present PivotTable values in addition to the
aggregation functions (sum, count, average etc) already covered.

Let’s see the different options available and demonstrate the use of percentages, running
totals and rankings.

2.3.1 SHOW AS % OF COLUMN TOTAL

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).

Note: Notice that there are many interesting options in the


Show Values As category.

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

2.3.2 SHOW AS RUNNING TOTAL

Now, let’s see how to create a running total in a PivotTable.

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.

Note: There is also an option for % 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 shows the finished PivotTable report.

Figure 51

2.3.3 SHOW AS RANKING

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.

Note: To change the values back to an aggregation field


such as sum, count or average; right-click a value, select
Show Values As and click No Calculation.

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

3 PIVOTTABLE STYLES AND


OTHER DESIGN SETTINGS
PivotTables come with a default style and layout. The default style has a blue fill colour
for headings and a thin blue border below the subtotal rows. The default layout is known
as compact form and the subtotals appear above the values.

Many of these settings can be changed. Let’s explore some of the design options available
for our PivotTables.

3.1 SHOW AND HIDE PIVOTTABLE TOTALS


Subtotals and grand totals are shown in your PivotTable by default. The subtotals are
displayed above the values.

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

3.2 PIVOTTABLE REPORT OPTIONS


There are three different report layouts to choose from for your PivotTables – Compact,
Outline and Tabular. The default report layout is the Compact form.

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

Click Design > Report Layout > Show in Tabular Form.

Figure 60

Figure 61 shows the PivotTable in Tabular form.

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.

Note: Click Design > Report Layout > Do Not Repeat


Item Labels to turn off the repeated labels.

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 shows a snapshot of the finished PivotTable.

Figure 64

It is useful to be aware of the different layouts and settings. PivotTables can be used for
more than just reporting.

3.3 PIVOTTABLE STYLES


There are many pre-set styles to choose from to help you format your PivotTables. You
can also create your own PivotTable styles. You can then apply the same style to another
PivotTable quickly.

3.2.1 CHANGE PIVOTTABLE STYLE

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

3.2.2 CREATE A PIVOTTABLE STYLE

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

3. Enter a Name for the new style.


4. Select the element that you want to format such as the Header Row or First
Column and click Format.

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

Note: You can also create a new PivotTable style by right


clicking an existing style and clicking Duplicate. You can
then modify this duplicated style giving you a head start
on formatting. When you create a new style, you begin
from nothing.

54
EXCEL PIVOTTABLES MADE EASY Filter your PivotTables and Using Slicers

4 FILTER YOUR PIVOTTABLES


AND USING SLICERS
There are three types of filter that you can use with your PivotTables to slice and dice the
data. They are the report filter, the field filter, and Slicers.

Let’s take a look at the three different filters and how and when you would use them.

4.1 REPORT FILTER


The report filter provides an easy way that we can filter the PivotTable results. In this
example, we want the potential to filter the PivotTable by store and/or by the month.

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).

Note: There is a [Month] field that could be used instead of


[Order Date]. Because we grouped by month earlier in the
book, we have not had a requirement for the [Month] field.

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

4.2 FIELD FILTER


The field filter is used to filter items from the field e.g., filter out products from the [Product]
field. My favourite use of this filter is to create a top N report. So, that is what I want to
do for this example.

Let’s create a PivotTable report to show the top 10 selling products.

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

4.3 USING SLICERS


Slicers are a modern filter tool. They are powerful, fast, visual and can filter multiple
PivotTables.

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 three PivotTables are;

• 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

4.3.1 INSERT A SLICER

We will insert two Slicers, one for the [Product Category] field and another for the [Order
Date] field (currently grouped as month).

1. Click a cell in the first PivotTable to make it the active PivotTable.


2. Click PivotTable Analyze > Insert Slicer (Figure 79).

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.

4.3.2 CONNECT A SLICER TO MULTIPLE PIVOTTABLES

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

Note: This used to be known as PivotTable Connections,


so may be named that in your version.

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

4.3.3 EXPLORE SLICER SETTINGS

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.

1. Select the [Order Date] Slicer.


2. Click Slicer and enter “Month” into the Slicer Caption box (Figure 86).

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.

1. Select the [Order Date] Slicer.


2. Click Slicer > Slicer Settings.
3. Check the box to Hide items with no data (Figure 89). Click Ok.

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

4.3.4 THE TIMELINE SLICER

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.

1. Select the first PivotTable.


2. Click PivotTable Analyze > Insert Timeline (Figure 91).

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.

It is very visual and easy to use.

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.

5.1 INSERT A PIVOTCHART


It is super simple to create a PivotChart from a PivotTable. We will create a column chart
from the Top 10 Products PivotTable we created in the previous chapter.

1. Click a cell in the Top 10 Products PivotTable.


2. Click PivotTable Analyze > PivotChart (Figure 97).

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

5.2 MODIFY THE PIVOTCHART


Let’s make some changes to the PivotChart. There are a few improvements to be made.

5.2.1 CHANGE THE CHART TITLE

We will start by changing the chart title to something meaningful (In Figure 99, you can
see that it currently says “Total”).

1. Click on the chart title.


2. Type “Top Products by Sales Value” and press Enter.

Note: As you type the text appears in the Formula Bar. It


only appears in the chart title when you press Enter.

73
EXCEL PIVOTTABLES MADE EASY Using PivotCharts

Figure 100 shows the chart with the new chart title.

Figure 100

5.2.2 REMOVE UNNECESSARY CHART ELEMENTS

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

5.2.3 ADD DATA LABELS

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.

1. Select the PivotChart.


2. Click Chart Elements > Data Labels (Figure 104).

Figure 104

Note: The default position for data labels is outside end.


You can specify a different position by clicking the arrow
that appears to the right of the Data Labels option on
mouse over.

5.2.4 CHANGE COLUMN COLOUR

The default colour with the Office theme is blue. Let’s change the colour of the columns
in our chart.

There are a few different ways of doing this. I like to right-click.

1. Right click on one of the columns you want to format.


2. Click Fill and choose the formatting you want to use.

In Figure 105, a green fill colour has been chosen.

76
EXCEL PIVOTTABLES MADE EASY Using PivotCharts

Figure 105

5.2.5 STOP THE PIVOTCHART WIDTH CHANGING

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.

This can be frustrating so we will disable it.

1. Select the PivotChart.


2. Click PivotChart Analyze > Options.
3. Navigate to the Layout & Format tab and uncheck the Autofit column widths on
update (Figure 106).

Note: You may notice that this window is named PivotTable


Options. We are actually changing the settings of the PivotTable,
and the changes will flow through to the PivotChart.

77
EXCEL PIVOTTABLES MADE EASY Using PivotCharts

Figure 106

78
EXCEL PIVOTTABLES MADE EASY Customise your PivotTables to Work for You

6 CUSTOMISE YOUR PIVOTTABLES


TO WORK FOR YOU
In previous chapters, we have seen a few PivotTable options and design settings that can
be changed to get what we want from our PivotTables.

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.

6.1 PIVOTTABLE OPTIONS


The full complement of PivotTable options can be seen when you open the PivotTable
Options window.

1. Click a cell in the PivotTable that you want to change the options for.
2. Click PivotTable Analyze > Options (Figure 107).

Figure 107

Note: You can also right click a PivotTable and click


PivotTable Options.

6.1.1 LAYOUT AND FORMAT

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

6.1.2 TOTALS AND FILTERS

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

6.1.3 DATA OPTIONS

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

6.2 DEFAULT PIVOTTABLE LAYOUT OPTIONS


The options we have changed so far only affect the active PivotTable. This is great because
you may not want all your PivotTables to behave in the same way.

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

Note: Changing the default PivotTable options is only


available from Excel 2019 and in Excel 365.

1. Click File > Options to open the Excel Options window.


2. Click Data, then the Edit Default Layout button (Figure 111).

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

7 WORKING WITH THE DATA


MODEL – AN INTRODUCTION
File: multiple-tables.xlsx

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.

7.1 INTRODUCTION TO OUR DATA


In this example, we have four tables that store information we need to use in a PivotTable.
Each of these tables are on different worksheets and are formatted as a table. The tables are;

• 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

7.2 CREATE RELATIONSHIPS BETWEEN TABLES


Usually, an Excel user would perform lookup formulas such as VLOOKUP or XLOOKUP
to retrieve the required columns from the other tables and combine them all into the Sales
table.

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

1. Click Data > Relationships (Figure 117).

Note: Your button may appear larger than mine shown in


the image.

Figure 117

2. The Manage Relationships window currently shows no relationships in the data


model. Click New (Figure 118).

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

• Table: The transactional or fact table. This is Sales in our example.


• Column (Foreign): This is the key column from the transactional table. In
lookup formula terminology, this is the lookup value.
• Related Table: The lookup table. For us this is Products, Reps and Stores.
• Related Column (Primary): The key field from the lookup table.

Note: The Column and Related Column do not have to be


named the same in the tables. In this example, the column
in Sales is named Product and in the Products table the
column is named Product ID.

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

7.3 CREATE A PIVOTTABLE FROM THE DATA MODEL


We will now create a PivotTable from the data model. We will use a field from each of the
four tables to demonstrate how the different tables are working together perfectly.

1. Click Insert > PivotTable.


2. Select Use this workbook’s Data Model and New Worksheet (Figure 125). Click
Ok.

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

4. Complete the PivotTable Fields pane shown in Figure 128.


• Move Product from the Products table to the Rows area.
• Move Sales Rep from the Reps table to the Filter area.
• Move Total from the Sales table to the Values area. Check that it is set to
Sum.
• Move Store from the Stores table to the Columns area.

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.

Figure 129 shows the completed PivotTable.

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

You might also like