0% found this document useful (0 votes)
18 views107 pages

Sample

Uploaded by

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

Sample

Uploaded by

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

Microsoft Excel 2019

Pivot Table Data Crunching

Bill Jelen
Michael Alexander
Microsoft Excel 2019 Pivot Table Data Crunching
Published with the authorization of Microsoft Corporation by:
Pearson Education, Inc.
Copyright © 2019 by Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must
be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any
form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions,
request forms, and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please
visit www.pearsoned.com/permissions/. No patent liability is assumed with respect to the use of the information contained
herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information
contained herein.
ISBN-13: 978-1-5093-0724-1
ISBN-10: 1-5093-0724-9
Library of Congress Control Number: 2018963618
Printed in the United States of America
1 18

Trademarks
Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks of the
Microsoft group of companies. All other marks are property of their respective owners.

Warning and Disclaimer


Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied.
The information provided is on an “as is” basis. The authors and the publisher shall have neither liability nor responsibility to
any person or entity with respect to any loss or damages arising from the information contained in this book.

Special Sales
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic
versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding inter-
ests), please contact our corporate sales department at [email protected] or (800) 382-3419.
For government sales inquiries, please contact [email protected].
For questions about sales outside the U.S., please contact [email protected].
Editor-in-Chief: Brett Bartow
Executive Editor: Loretta Yates
Sponsoring Editor: Charvi Arora
Managing Editor: Sandra Schroeder
Senior Project Editor: Tracey Croom
Project Editor: Charlotte Kughen
Copy Editor: Kitty Wilson
Indexer: Ken Johnson
Proofreader: Paula Lowell
Technical Editor: Bob Umlas
Publishing Coordinator: Cindy Teeters
Cover Designer: Twist Creative, Seattle
Compositor: Bronkella Publishing LLC
Graphics: TJ Graham Art
To Ashvina Sharma and his team at Microsoft. Thanks for Pivot
Table Defaults!
—Bill Jelen
To my 12 fans at datapigtechnologies.com.
—Mike Alexander
Contents at a Glance
Introduction xxiii

CHAPTER 1 Pivot table fundamentals 1


CHAPTER 2 Creating a basic pivot table 11
CHAPTER 3 Customizing a pivot table 43
CHAPTER 4 Grouping, sorting, and filtering pivot data 75
CHAPTER 5 Performing calculations in pivot tables 121
CHAPTER 6 Using pivot charts and other visualizations 149
CHAPTER 7 Analyzing disparate data sources with pivot tables 175
CHAPTER 8 Sharing dashboards with Power BI 207
CHAPTER 9 Using cube formulas with the Data Model or OLAP data 231
CHAPTER 10 Unlocking features with the Data Model and Power Pivot 261
CHAPTER 11 Analyzing geographic data with 3D Map 289
CHAPTER 12 Enhancing pivot table reports with macros 303
CHAPTER 13 Using VBA to create pivot tables 323
CHAPTER 14 Advanced pivot table tips and techniques 387
CHAPTER 15 Dr. Jekyll and Mr. GetPivotData 425

Index 443

v

Contents
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

Chapter 1 Pivot table fundamentals 1


Why you should use a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
When to use a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Anatomy of a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Values area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Rows area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Columns area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Filters area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Pivot tables behind the scenes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Pivot table backward compatibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
A word about compatibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Chapter 2 Creating a basic pivot table 11


Ensuring that data is in a Tabular layout. . . . . . . . . . . . . . . . . . . . . . . . . . 12
Avoiding storing data in section headings. . . . . . . . . . . . . . . . . . . . . . . . 12
Avoiding repeating groups as columns . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Eliminating gaps and blank cells in the data source. . . . . . . . . . . . . . . 14
Applying appropriate type formatting to fields. . . . . . . . . . . . . . . . . . . 14
Summary of good data source design . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
How to create a basic pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Adding fields to a report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Fundamentals of laying out a pivot table report. . . . . . . . . . . . . . . . . . 22
Adding layers to a pivot table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Rearranging a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Creating a report filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Understanding the Recommended PivotTable and the Ideas features . . . 28
Using slicers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Creating a standard slicer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Creating a Timeline slicer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
vii

Keeping up with changes in the data source . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Dealing with changes made to the existing data source. . . . . . . . . . . 36
Dealing with an expanded data source range due to the addition
of rows or columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Sharing the pivot cache. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Side effects of sharing a pivot cache. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Saving time with new PivotTable tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Deferring layout updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Starting over with one click. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Relocating a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Chapter 3 Customizing a pivot table 43


Making common cosmetic changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Applying a table style to restore gridlines. . . . . . . . . . . . . . . . . . . . . . . . 45
Changing the number format to add thousands separators. . . . . . . 46
Replacing blanks with zeros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Changing a field name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Making report layout changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Using the Compact layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Using the Outline layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Using the traditional Tabular layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Controlling blank lines, grand totals, and other settings. . . . . . . . . . .56
Customizing a pivot table’s appearance with styles and themes. . . . . . . . . 59
Customizing a style. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Modifying styles with document themes. . . . . . . . . . . . . . . . . . . . . . . . . . 61
Changing summary calculations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
The Excel team fixed the Count Of Revenue bug. . . . . . . . . . . . . . . . . . 62
Changing the calculation in a value field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Showing percentage of total. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Using % Of to compare one line to another line. . . . . . . . . . . . . . . . . . 66
Showing rank. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Tracking running total and percentage of running total. . . . . . . . . . . 67
Displaying a change from a previous field. . . . . . . . . . . . . . . . . . . . . . . . 68
Tracking the percentage of a parent item. . . . . . . . . . . . . . . . . . . . . . . . 69
Tracking relative importance with the Index option. . . . . . . . . . . . . . . 69
viii Contents
Adding and removing subtotals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Suppressing subtotals with many row fields. . . . . . . . . . . . . . . . . . . . . . 70
Adding multiple subtotals for one field . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Formatting one cell is new in Office 365 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Chapter 4 Grouping, sorting, and filtering pivot data 75


Using the PivotTable Fields list. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Docking and undocking the PivotTable Fields list. . . . . . . . . . . . . . . . . 77
Rearranging the PivotTable Fields list. . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Using the Areas section drop-downs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Sorting in a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Sorting customers into high-to-low sequence based on revenue. . 79
Using a manual sort sequence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Using a custom list for sorting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Filtering a pivot table: an overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Using filters for row and column fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Filtering using the check boxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Filtering using the search box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Filtering using the Label Filters option. . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Filtering a Label column using information in a Values column. . . . 91
Creating a top-five report using the Top 10 filter. . . . . . . . . . . . . . . . . . 93
Filtering using the Date filters in the Label drop-down menu. . . . . . 94
Filtering using the Filters area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Adding fields to the Filters area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Choosing one item from a filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Choosing multiple items from a filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Replicating a pivot table report for each item in a filter. . . . . . . . . . . 97
Filtering using slicers and timelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Using timelines to filter by date. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Driving multiple pivot tables from one set of slicers . . . . . . . . . . . . . 102
Grouping and creating hierarchies in a pivot table. . . . . . . . . . . . . . . . . . . . . 104
Grouping numeric fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Grouping date fields manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Including years when grouping by months. . . . . . . . . . . . . . . . . . . . . . . 110

Contents ix
Grouping date fields by week . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
AutoGrouping pivot table dates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Understanding how Excel decides what to AutoGroup. . . . . . . . . . . . 111
Using AutoGroup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Creating an easy year-over-year report. . . . . . . . . . . . . . . . . . . . . . . . . . 113
Creating hierarchies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

Chapter 5 Performing calculations in pivot tables 121


Introducing calculated fields and calculated items. . . . . . . . . . . . . . . . . . . . . . 121
Method 1: Manually add a calculated field to the data source . . . . 122
Method 2: Use a formula outside a pivot table to create a
calculated field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Method 3: Insert a calculated field directly into a pivot table. . . . . 124
Creating a calculated field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Creating a calculated item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Understanding the rules and shortcomings of pivot table calculations. . 137
Remembering the order of operator precedence. . . . . . . . . . . . . . . . 138
Using cell references and named ranges. . . . . . . . . . . . . . . . . . . . . . . . 139
Using worksheet functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Using constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Referencing totals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Rules specific to calculated fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Rules specific to calculated items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Managing and maintaining pivot table calculations . . . . . . . . . . . . . . . . . . . 146
Editing and deleting pivot table calculations. . . . . . . . . . . . . . . . . . . . 146
Changing the solve order of calculated items. . . . . . . . . . . . . . . . . . . . 147
Documenting formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Chapter 6 Using pivot charts and other visualizations 149


What is a pivot chart…really?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Creating a pivot chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Understanding pivot field buttons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Creating a Pivot Chart from Scratch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

x Contents
Keeping pivot chart rules in mind. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Changes in the underlying pivot table affect a pivot chart . . . . . . . 154
Placement of data fields in a pivot table might not be best
suited for a pivot chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
A few formatting limitations still exist in Excel 2019. . . . . . . . . . . . . . 156
Examining alternatives to using pivot charts . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Method 1: Turn the pivot table into hard values. . . . . . . . . . . . . . . . . . 162
Method 2: Delete the underlying pivot table. . . . . . . . . . . . . . . . . . . . 162
Method 3: Distribute a picture of the pivot chart . . . . . . . . . . . . . . . . 163
Method 4: Use cells linked back to the pivot table as the source
data for the chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Using conditional formatting with pivot tables. . . . . . . . . . . . . . . . . . . . . . . . 165
An example of using conditional formatting . . . . . . . . . . . . . . . . . . . . 165
Preprogrammed scenarios for condition levels. . . . . . . . . . . . . . . . . . 167
Creating custom conditional formatting rules. . . . . . . . . . . . . . . . . . . . . . . . . 168
Using Power BI Custom Visuals in Excel . . . . . . . . . . . . . . . . . . . . . . . . . 173
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

Chapter 7 Analyzing disparate data sources with pivot tables 175


Using the Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Building out your first Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Managing relationships in the Data Model. . . . . . . . . . . . . . . . . . . . . . 179
Adding a new table to the Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . 180
Limitations of the Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Building a pivot table using external data sources. . . . . . . . . . . . . . . . . . . . . . 181
Building a pivot table with Microsoft Access data. . . . . . . . . . . . . . . . . 181
Building a pivot table with SQL Server data . . . . . . . . . . . . . . . . . . . . . 184
Leveraging Power Query to extract and transform data. . . . . . . . . . . . . . . . 187
Power Query basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Understanding applied steps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Refreshing Power Query data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Managing existing queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Understanding column-level actions . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Understanding table actions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

Contents xi
Power Query connection types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
One more Power Query example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

Chapter 8 Sharing dashboards with Power BI 207


Getting started with Power BI Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Preparing data in Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Importing data to Power BI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Getting oriented to Power BI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Preparing data in Power BI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Defining synonyms in Power BI Desktop. . . . . . . . . . . . . . . . . . . . . . . . 213
Building an interactive report with Power BI Desktop. . . . . . . . . . . . . . . . . . 213
Building your first visualization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Building your second visualization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Cross-filtering charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Creating a drill-down hierarchy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Importing a custom visualization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Publishing to Power BI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Designing for the mobile phone. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Publishing to a workspace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Using artificial intelligence for Insights. . . . . . . . . . . . . . . . . . . . . . . . . . 224
Using Q&A to query data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Designing a workbook as an interactive web page. . . . . . . . . . . . . . . . . . . . . 226
Sharing a link to a web workbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

Chapter 9 Using cube formulas with the Data Model or


OLAP data 231
Converting your pivot table to cube formulas. . . . . . . . . . . . . . . . . . . . . . . . . 232
Introduction to OLAP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Connecting to an OLAP cube. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Understanding the structure of an OLAP cube . . . . . . . . . . . . . . . . . . . . . . . . 242
Understanding the limitations of OLAP pivot tables. . . . . . . . . . . . . . . . . . . 244
Creating an offline cube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

xii Contents
Breaking out of the pivot table mold with cube functions. . . . . . . . . . . . . . 248
Exploring cube functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Adding calculations to OLAP pivot tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Creating calculated measures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Creating calculated members. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Managing OLAP calculations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Performing what-if analysis with OLAP data. . . . . . . . . . . . . . . . . . . . . 258
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Chapter 10 Unlocking features with the Data Model and


Power Pivot 261
Replacing VLOOKUP with the Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Unlocking hidden features with the Data Model. . . . . . . . . . . . . . . . . . . . . . . 266
Counting Distinct in a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Including filtered items in totals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Creating median in a pivot table using DAX measures. . . . . . . . . . . 269
Reporting text in the Values area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Processing big data with Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Adding a new column using Power Query. . . . . . . . . . . . . . . . . . . . . . . 275
Power Query is like the Macro Recorder but better. . . . . . . . . . . . . . 276
Avoiding the Excel grid by loading to the Data Model . . . . . . . . . . . 277
Adding a linked table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Defining a relationship between two tables. . . . . . . . . . . . . . . . . . . . . 279
Adding calculated columns in the Power Pivot grid. . . . . . . . . . . . . . 281
Sorting one column by another column. . . . . . . . . . . . . . . . . . . . . . . . . 282
Creating a pivot table from the Data Model. . . . . . . . . . . . . . . . . . . . . 283
Using advanced Power Pivot techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Handling complicated relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Using time intelligence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Overcoming limitations of the Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Enjoying other benefits of Power Pivot. . . . . . . . . . . . . . . . . . . . . . . . . . 287
Learning more. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

Contents xiii
Chapter 11 Analyzing geographic data with 3D Map 289
Analyzing geographic data with 3D Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Preparing data for 3D Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Geocoding data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Building a column chart in 3D Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Navigating through the map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Labeling individual points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Building pie or bubble charts on a map. . . . . . . . . . . . . . . . . . . . . . . . . 294
Using heat maps and region maps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Exploring 3D Map settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Fine-tuning 3D Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Combining two data sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Animating data over time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Building a tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Creating a video from 3D Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Chapter 12 Enhancing pivot table reports with macros 303


Using macros with pivot table reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Recording a macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Creating a user interface with form controls. . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Altering a recorded macro to add functionality . . . . . . . . . . . . . . . . . . . . . . . 308
Inserting a scrollbar form control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Creating a macro using Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Chapter 13 Using VBA to create pivot tables 323


Enabling VBA in your copy of Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Using a file format that enables macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Visual Basic Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Visual Basic tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
The macro recorder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
Understanding object-oriented code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

xiv Contents
Learning tricks of the trade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Writing code to handle a data range of any size. . . . . . . . . . . . . . . . . 327
Using super-variables: Object variables. . . . . . . . . . . . . . . . . . . . . . . . . 328
Using With and End With to shorten code. . . . . . . . . . . . . . . . . . . . . . 329
Understanding versions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Building a pivot table in Excel VBA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Adding fields to the data area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Formatting the pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Dealing with limitations of pivot tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Filling blank cells in the data area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Filling blank cells in the row area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Preventing errors from inserting or deleting cells. . . . . . . . . . . . . . . . 336
Controlling totals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Converting a pivot table to values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Pivot table 201: Creating a report showing revenue by category. . . . . . . . 341
Ensuring that Tabular layout is utilized. . . . . . . . . . . . . . . . . . . . . . . . . . 344
Rolling daily dates up to years. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Eliminating blank cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Controlling the sort order with AutoSort. . . . . . . . . . . . . . . . . . . . . . . . 347
Changing the default number format. . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Suppressing subtotals for multiple row fields. . . . . . . . . . . . . . . . . . . . 348
Copying a finished pivot table as values to a new workbook . . . . . 349
Handling final formatting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Adding subtotals to get page breaks. . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Putting it all together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Calculating with a pivot table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Addressing issues with two or more data fields. . . . . . . . . . . . . . . . . . 355
Using calculations other than Sum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Using calculated data fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Using calculated items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Calculating groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Using Show Values As to perform other calculations. . . . . . . . . . . . . 362
Using advanced pivot table techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Using AutoShow to produce executive overviews. . . . . . . . . . . . . . . . 365
Using ShowDetail to filter a Recordset. . . . . . . . . . . . . . . . . . . . . . . . . . 367

Contents xv
Creating reports for each region or model. . . . . . . . . . . . . . . . . . . . . . 369
Manually filtering two or more items in a pivot field. . . . . . . . . . . . . 373
Using the conceptual filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Using the search filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Setting up slicers to filter a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . 378
Using the Data Model in Excel 2019. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Adding both tables to the Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . 381
Creating a relationship between the two tables . . . . . . . . . . . . . . . . . 382
Defining the pivot cache and building the pivot table. . . . . . . . . . . . 383
Adding model fields to the pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . 383
Adding numeric fields to the Values area. . . . . . . . . . . . . . . . . . . . . . . . 383
Putting it all together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

Chapter 14 Advanced pivot table tips and techniques 387


Tip 1: Force pivot tables to refresh automatically. . . . . . . . . . . . . . . . . . . . . . . 388
Tip 2: Refresh all pivot tables in a workbook at the same time. . . . . . . . . . 388
Tip 3: Sort data items in a unique order, not ascending or
descending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
Tip 4: Using (or prevent using) a custom list for sorting your
pivot table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Tip 5: Use pivot table defaults to change the behavior of all future
pivot tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Tip 6: Turn pivot tables into hard data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Tip 7: Fill the empty cells left by row fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Option 1: Implement the Repeat All Item Labels feature. . . . . . . . . . 394
Option 2: Use Excel’s Go To Special functionality . . . . . . . . . . . . . . . . 395
Tip 8: Add a rank number field to a pivot table. . . . . . . . . . . . . . . . . . . . . . . . 396
Tip 9: Reduce the size of pivot table reports. . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Delete the source data worksheet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Tip 10: Create an automatically expanding data range. . . . . . . . . . . . . . . . . 399
Tip 11: Compare tables using a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Tip 12: AutoFilter a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Tip 13: Force two number formats in a pivot table . . . . . . . . . . . . . . . . . . . . . 404

xvi Contents
Tip 14: Format individual values in a pivot table . . . . . . . . . . . . . . . . . . . . . . . 405
Tip 15: Format sections of a pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Tip 16: Create a frequency distribution with a pivot table. . . . . . . . . . . . . . . 409
Tip 17: Use a pivot table to explode a data set to different tabs. . . . . . . . . 410
Tip 18: Apply restrictions on pivot tables and pivot fields. . . . . . . . . . . . . . . 412
Pivot table restrictions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Pivot field restrictions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Tip 19: Use a pivot table to explode a data set to different workbooks. . 415
Tip 20: Use percentage change from previous for year-over-year . . . . . . 417
Tip 21: Do a two-way VLOOKUP with Power Query. . . . . . . . . . . . . . . . . . . . 419
Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

Chapter 15 Dr. Jekyll and Mr. GetPivotData 425


Avoiding the evil GetPivotData problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Preventing GetPivotData by typing the formula. . . . . . . . . . . . . . . . . 429
Simply turning off GetPivotData. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Speculating on why Microsoft forced GetPivotData on us. . . . . . . . 430
Using GetPivotData to solve pivot table annoyances. . . . . . . . . . . . . . . . . . . 431
Building an ugly pivot table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Building the shell report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Using GetPivotData to populate the shell report. . . . . . . . . . . . . . . . 437
Updating the report in future months . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

Contents xvii
Acknowledgments

Thanks to Mike Alexander for being my coauthor on the five previous editions of this
book. At Microsoft, thanks to the Excel team for always being willing to answer questions
about various features. At MrExcel.com, thanks to an entire community of people who are
passionate about Excel. Finally, thanks to my wife, Mary Ellen, for her support during the
writing process.

—Bill Jelen

Thanks to Bill Jelen for deciding to coauthor this book with me many editions ago. His
knowledge of Excel still blows me away to this day. My deepest thanks to the professionals
at Pearson Education for all the hours of work put into bringing this book to life. Thanks
also to Bob Umlas, whose technical editing has helped us make numerous improvements
to the examples and text in this book. Finally, a special thank you goes to the wife and kids
for putting up with all the time I spent locked away on this project.

—Mike Alexander

Acknowledgments xix
About the Authors

Bill Jelen, Excel MVP and the host of MrExcel.com, has been using spreadsheets since
1985, and he launched the MrExcel.com website in 1998. Bill was a regular guest on Call
for Help with Leo Laporte and has produced more than 2,200 episodes of his daily video
podcast, Learn Excel from MrExcel. He is the author of 57 books about Microsoft Excel
and writes the monthly Excel column for Strategic Finance magazine. Before founding
MrExcel.com, Bill spent 12 years in the trenches, working as a financial analyst for the
finance, marketing, accounting, and operations departments of a $500 million public
company. He lives in Merritt Island, Florida, with his wife, Mary Ellen.

Mike Alexander is a Microsoft Certified Application Developer (MCAD) and author of


several books on advanced business analysis with Microsoft Access and Excel. He has
more than 15 years of experience consulting and developing Office solutions. Mike has
been named a Microsoft MVP for his ongoing contributions to the Excel community.

About the Authors xxi


Introduction

The pivot table is the single most powerful tool in all of Excel. Pivot tables came along
during the 1990s, when Microsoft and Lotus were locked in a bitter battle for domi-
nance of the spreadsheet market. The race to continually add enhanced features to their
respective products during the mid-1990s led to many incredible features, but none as
powerful as the pivot table.

With a pivot table, you can transform one million rows of transactional data into a
summary report in seconds. If you can drag a mouse, you can create a pivot table. In
addition to quickly summarizing and calculating data, pivot tables enable you to change
your analysis on the fly by simply moving fields from one area of a report to another.

No other tool in Excel gives you the flexibility and analytical power of a pivot table.

What you will learn from this book


It is widely agreed that close to 60 percent of Excel customers leave 80 percent of Excel
untouched—that is, most people do not tap into the full potential of Excel’s built-in utili-
ties. Of these utilities, the most prolific by far is the pivot table. Despite the fact that pivot
tables have been a cornerstone of Excel for almost 20 years, they remain one of the most
underutilized tools in the entire Microsoft Office suite.

Having picked up this book, you are savvy enough to have heard of pivot tables—and
you have perhaps even used them on occasion. You have a sense that pivot tables pro-
vide a power that you are not using, and you want to learn how to leverage that power to
increase your productivity quickly.

Within the first two chapters, you will be able to create basic pivot tables, increase
your productivity, and produce reports in minutes instead of hours. Within the first seven
chapters, you will be able to output complex pivot reports with drill-down capabilities
and accompanying charts. By the end of the book, you will be able to build a dynamic
pivot table reporting system.

What is new in Excel 2019’s pivot tables


Luckily, Microsoft continues to invest heavily in business intelligence (BI), and pivot tables
are the front end that let you access the new features. Some of the features added to
Excel 2019 pivot tables include the following:

xxiii

■■ You can specify default settings for all future pivot tables. If you want all pivot
tables to start in Tabular layout instead of Compact layout, you can specify this.
Do you prefer Classic layout or do you always replace empty cells with zero? Visit
File, Options, Data, Pivot Table Defaults to change the settings for all future pivot
tables.

■■ The automatic date grouping introduced in Excel 2016 pivot tables can now be
turned off. The setting is found in File, Options, Data. The feature became un-
popular after the release of Excel 2016.

■■ Pivot tables will be doing more summing and less counting. Previously, if you had
a column with revenue and a few empty cells, the pivot table would choose to
Count instead of Sum. In Excel 2019, a mix of empty cells and numeric cells will be
treated like a numeric column and will default to Sum instead of Count.

■■ Power Pivot is now included in all Windows versions of Excel 2019 and Office 365.
During the tenure of Office 2013–2016, only parts of Power Pivot were available.
Although some of the Power Pivot functionality was available if you chose Add
This Data To The Data Model while creating a pivot table, you can now access the
Power Pivot tab in the ribbon. This allows you to create and view relationships in a
diagram view. You can choose to sort one column by another column.

■■ With Power Pivot in Excel 2019, your pivot tables benefit from any new functions
added to the DAX formula language. If you ever wanted to do Median in a pivot
table or even report Text fields in the Values area, the new DAX functions such as
MEDIAN and CONCATENATEX allow this to happen.

■■ Power View is being de-emphasized. Microsoft is replacing Power View with Power
BI Desktop. You will find it difficult to locate the Power View icons in Excel 2019.

■■ If you are using Office 365, you will have access to the Insights command on the
Insert tab. This command uses artificial intelligence to suggest 30 interesting
charts or pivot tables that can be created from your data.

Case Study: Life Before Pivot Tables


Say that your manager asks you to create a one-page summary of a sales data-
base. He would like to see total revenue by region and product. Suppose you
do not know how to use pivot tables. You will have to use dozens of keystrokes
or mouse clicks to complete this task.
First, you have to build the outline of the report:
1. Copy the Product column to a blank section of the worksheet.

2. Select Data, Remove Duplicates to eliminate the duplicates.

xxiv Introduction
3. Delete the Product heading.

4. Copy the unique list of products and then use Paste Special Transpose to
turn the list sideways.

5. Delete the vertical list of products.

6. Copy the Region column to a blank section of the worksheet.

7. Select Data, Remove Duplicates to remove the duplicates.

8. Delete the Region heading.

9. Cut and paste the products so they appear to the left of and below the
regions.

At this point, with 27 mouse clicks or keystrokes, you’ve built the shell of the
final report, but there are no numbers inside yet (see Figure I-1).

FIGURE I-1 It took 27 clicks to get to this point.

Next, you need to build the relatively new SUMIFS function to total the rev-
enue for the intersection of a region and product. As shown in Figure I-2, the
formula =SUMIFS($G$2:$G$564,$C$2:$C$564,L$1,$B$2:$B$564,$K2) does the
trick. It takes 52 characters plus the Enter key to finish the formula, but I man-
aged to enter the formula in 36 clicks or keystrokes by using some clever navi-
gation tricks I’ve learned over the years.

If this were the year 2006, the SUMIFS function would have been an uglier
FIGURE I-2
SUMPRODUCT function.

If you are adept at using the Fill handle, you need just two more mouse drags
to copy the formula to the rest of the table.

Introduction xxv
Enter the heading Total for the total row and for the total column. You can do
this in nine keystrokes if you type the first heading, press Ctrl+Enter to stay in
the same cell, and then use Copy, select the cell for the second heading, and
use Paste.
If you select K1:P6 and press Alt+= (that is, Alt and the equal sign key), you can
add the total formula in three keystrokes.
With this method, which takes 77 clicks or keystrokes, you end up with a nice
summary report, as shown in Figure I-3. If you could pull this off in 5 or 10
minutes, you would probably be fairly proud of your Excel prowess; there are
some good tricks among those 77 operations.

FIGURE I-3 A mere 77 operations later, you have a summary report.

You hand the report to your manager. Within a few minutes, he comes back
with one of the following requests, which will certainly cause a lot of rework:
■■ Could you put products down the side and regions across the top?

■■ Could you show me the same report for only the manufacturing customers?

■■ Could you show profit instead of revenue?

■■ Could you copy this report for each of the customers?

Invention of the pivot table


When the actual pivot table was invented is in dispute. The Excel team coined the term
pivot table, which appeared in Excel in 1993. However, the concept was not new. Pito
Salas and his team at Lotus were working on the pivot table concept in 1986 and released
Lotus Improv in 1991. Before then, Javelin offered functionality similar to that of pivot
tables.

The core concept behind a pivot table is that the data, formulas, and data views are
stored separately. Each column has a name, and you can group and rearrange the data
by dragging field names to various positions on the report.

xxvi Introduction
Case Study: Life After Pivot Tables
Say that you’re tired of working so hard to remake reports every time your
manager wants a change. You’re in luck: You can produce the same report as
in the last case study but use a pivot table instead. Excel 2019 offers you 10
thumbnails of recommended pivot tables to get you close to the goal. Follow
these steps:
1. Click the Insert tab of the ribbon.

2. Click Recommended PivotTables. The first recommended item is Revenue


By Region (see Figure I-4).

FIGURE I-4 The first recommended pivot table is as close as you will get to the required
report.

3. Click OK to accept the first pivot table.

4. Drag the Product field from the PivotTable Fields list to the Columns area
(see Figure I-5).

Introduction xxvii
FIGURE I-5 To finish the report, drag the Product heading to the Columns area.

5. Clear Field Headers on the right side of the ribbon.

With just five clicks of the mouse, you have the report shown in Figure I-6.

FIGURE I-6 It took five clicks to create this report.

In addition, when your manager comes back with a request like the ones near
the end of the prior case study, you can easily use the pivot table to make the
changes. Here’s a quick overview of the changes you’ll learn to make in the
chapters that follow:
■■ Could you put products down the side and regions across the top? (This
change will take you 10 seconds: Drag Product to Rows and Region to Col-
umns.)

■■ Could you show me the same report for only the manufacturing customers?
(15 seconds: Select Insert Slicer, Sector; click OK; click Manufacturing.)

xxviii Introduction
■■ Could you show profit instead of revenue? (10 seconds: Clear the check box
for Revenue, select the check box for Profit.)

■■ Could you copy this report for each of the customers? (30 seconds: Move
Customer to Report Filter, open the tiny drop-down menu next to the Op-
tions button, choose Show Report Filter Pages, click OK.)

Excel 2019 versus Office 365


The title of this book says Excel 2019. In reality, no one should be buying Office 2019.
Instead, it is likely that you are renting Office 365. As of May 2018, Office 2019 and Office
365 were nearly equivalent.

Here’s why the authors hope that you did not purchase Office 2019: The features
in Office 2019 will not change. The features in Office 365 will constantly evolve and
improve. The people who have been using Office 365 have enjoyed the new features
described earlier in this chapter one to two years before the people who purchased Of-
fice 2019.

Because the title of this book says Excel 2019, the screenshots show the Excel 2019 rib-
bon. However, anyone using Office 365 will have a new look to the ribbon.

Microsoft reduced the number of colors in the Office 365 ribbon. The selected Ribbon
tab is now underlined instead of being a different color. Compare the Excel 2019 Insert
tab in Figure I-7 with the Office 365 Insert tab in Figure I-8.

FIGURE I-7 The Excel 2019 ribbon is very similar to the Excel 2016 ribbon.

Introduction xxix
FIGURE I-8 The Office 365 ribbon introduced in the summer of 2018 uses a new font and fewer
colors.

Microsoft is experimenting with a new ribbon that goes back to a single row like the
Office 2013 menus. As of the summer of 2018, that new ribbon will debut with Outlook
and Excel Online and only for Office 365 customers. It remains to be seen if that ribbon
ever makes it to the desktop version of Excel.

New features in Office 365


After this book is printed, the Excel team will release new features for Excel. Anyone with
an Office 365 subscription will receive the new features. People with Excel 2019 will not
get the new features.

For any new features introduced to Office 365, the owners of Excel 2019 will have to
purchase Office 2022 in order to access those features.

But what is even worse, some features introduced will be marked as Office 365 Exclu-
sive features. Those features will never be available to customers who buy the perpetual
versions of Office, such as Office 2016, Office 2019, or Office 2022.

One such feature introduced in early 2018 is the Insights feature. This feature will send
up to 250,000 cells of your data to a Microsoft server where artificial intelligence looks for
trends in your data. The first few results from Insights are very similar to the Insert Recom-
mended PivotTable logic introduced in Excel 2013 and shown previously in Figure I-4.

However, if you click the More link, Insights often provides two to three dozen sug-
gestions. Most suggestions will insert a pivot table and a pivot chart. In the first preview
of Insights, Excel will look for: rank, evenness, trend, composite signal, attribution, out-
standing top two, monotonicity (always increasing or always decreasing), and unimodal-
ity (having a single peak data point).

When I used the data set from this Introduction with Insights in Office 365, Microsoft
suggested 32 different possible results. One is shown in Figure I-9.

xxx Introduction
FIGURE I-9 Excel used artificial intelligence to spot these outliers.

If you regularly purchased every new version of Office, it will cost less to rent Office
365 at $10 a month than to pay $399 for the perpetual version of Office every 36 months.
Office 365 offers more features than Excel 2019. Unless your buying pattern is to only
buy every second or third version of Office, upgrading to Office 365 makes sense.

Who this book is for


This book is a comprehensive-enough reference for hard-core analysts yet relevant to
casual users of Excel.

We assume that you are comfortable navigating in Excel and that you have some large
data sets that you need to summarize.

How this book is organized


The bulk of the book covers how to use pivot tables in the Excel user interface. Chapter
10, “Unlocking features with the Data Model and Power Pivot,” delves into the Power
Pivot window. Chapter 13, “Using VBA to create pivot tables,” describes how to create
pivot tables in Excel’s powerful VBA macro language. Anyone who has a firm grasp of
basics such as preparing data, copying, pasting, and entering simple formulas should not
have a problem understanding the concepts in this book.

Introduction xxxi
CHAPTER 4

Grouping, sorting, and filtering


pivot data
In this chapter, you will:
• Use the PivotTable Fields list
• Sort in a pivot table
• Filter a pivot table: an overview
• Use filters for row and column fields
• Filter using the Filters area
• Group and create hierarchies in a pivot table

W ith Excel 2019, Microsoft has reversed the auto date grouping added to Excel 2016. Removing the
feature was a good move, as the feature proved hard to predict. For anyone who loved the auto
grouping and the Drill-Down and Drill-Up features, you can re-create them, although it requires a few
extra steps. Grouping will be covered last in this chapter.

First, a quick overview of the PivotTable Fields. Then, a detailed look at sorting, filtering, and group-
ing a pivot table.

Using the PivotTable Fields list


The entry points for sorting and filtering are spread throughout the Excel interface. It is worth taking a
closer look at the row header drop-downs and the PivotTable Fields list before diving in to sorting and
filtering.

As you’ve seen in these pages, I rarely use the Compact form for a pivot table. I use Pivot Table
Defaults to make sure my pivot tables start in Tabular layout instead of Compact layout. Although there
are many good reasons for this, one is illustrated in Figures 4-1 and 4-2.

75

FIGURE 4-1 The drop-down menu in B3 for Customer is separate from the drop-down menu for Region.

FIGURE 4-2 In Compact form, one single drop-down menu tries to control sorting and filtering for all the row
fields.

In Figure 4-1, a Region drop-down menu appears in A3. A Customer drop-down menu appears in
B3. Each of these separate drop-downs offers great settings for sorting and filtering.

When you leave the pivot table in the Compact form, there are not separate headings for Region
and Customer. Both fields are crammed into column A, with the silly heading Row Labels. This means
the drop-down menu always offers sorting and filtering options for Region. Every time you go back to
the A3 drop-down menu with hopes of filtering or sorting the Customer field, you have to reselect Cus-
tomer from a drop-down at the top of the menu. This is an extra click. If you are making five changes

76 Chapter 4 Grouping, sorting, and filtering pivot data


to the Customer field, you are reselecting Customer over and over and over and over and over. This
should be enough to convince you to abandon the Compact layout.

If you decide to keep the Compact layout and get frustrated with the consolidated Row Labels
drop-down menu, you can directly access the invisible drop-down menu for the correct field by using
the PivotTable Fields list, which contains a visible drop-down menu for every field in the areas at the
bottom. Those visible drop-down menus do not contain the sorting and filtering options.

The good drop-down menus are actually in the top of the Fields list, but you have to hover over the
field to see the drop-down menu appear. After you hover as shown in Figure 4-3, you can directly ac-
cess the same customer drop-down menu shown in Figure 4-1.

FIGURE 4-3 Hover over the field in the top of the Fields list to directly access the sorting and filtering settings for
that field.

Docking and undocking the PivotTable Fields list


The PivotTable Fields list starts out docked on the right side of the Excel window. Hover over the green
PivotTable Fields heading in the pane, and the mouse pointer changes to a four-headed arrow. Drag to
the left to enable the pane to float anywhere in your Excel window.

After you have undocked the PivotTable Fields list, you might find that it is difficult to redock it on
either side of the screen. To redock the Fields list, you must grab the title bar and drag until at least 85%
of the Fields list is off the edge of the window. Pretend that you are trying to remove the floating Fields
list completely from the screen. Eventually, Excel gets the hint and redocks it. Note that you can dock
the PivotTable Fields list on either the right side or the left side of the screen.

Rearranging the PivotTable Fields list


As shown in Figure 4-4, a small gear-wheel icon appears near the top of the PivotTable Fields list. Select
this drop-down menu to see its five possible arrangements. Although the default is to have the Fields
section at the top of the list and the Areas section at the bottom of the list, four other arrangements are

Chapter 4 Grouping, sorting, and filtering pivot data 77


possible. Other options let you control whether the fields in the list appear alphabetically or in the same
sequence that they appeared in the original data set.

FIGURE 4-4 Use this drop-down menu to rearrange the PivotTable Fields list.

The final three arrangements offered in the drop-down menu are rather confusing. If someone
changes the PivotTable Fields list to show only the Areas section, you cannot see new fields to add to
the pivot table.

If you ever encounter a version of the PivotTable Fields list with only the Areas section (see Figure
4-4) or only the Fields section, remember that you can return to a less-confusing view of the data by
using the arrangement drop-down menu.

Using the Areas section drop-downs


As shown in Figure 4-5, every field in the Areas section has a visible drop-down arrow. When you select
this drop-down arrow, you see four categories of choices:

■■ The first four choices enable you to rearrange the field within the list of fields in that area of the
pivot table. You can accomplish this by dragging the field up or down in the area.

■■ The next four choices enable you to move the field to a new area. You could also accomplish
this by dragging the field to a new area.

■■ The next choice enables you to remove the field from the pivot table. You can also accomplish
this by dragging the field outside the Fields list.

■■ The final choice displays the Field Settings dialog box for the field.

78 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-5 Use this drop-down menu to rearrange the fields in your pivot table.

Sorting in a pivot table


Items in the row area and column area of a pivot table are sorted in ascending order by any custom list
first. This allows weekday and month names to sort into Monday, Tuesday, Wednesday, … instead of the
alphabetical order Friday, Monday, Saturday, …, Wednesday.

If the items do not appear in a custom list, they will be sorted in ascending order. This is fine, but in
many situations, you want the customer with the largest revenue to appear at the top of the list. When
you sort in descending order using a pivot table, you are setting up a rule that controls how that field is
sorted, even after new fields are added to the pivot table.

Tip Excel 2019 includes four custom lists by default, but you can add your own custom list
to control the sort order of future pivot tables. See the section “Using a custom list for sort-
ing,” later in this chapter.

Sorting customers into high-to-low sequence based on revenue


Three pivot tables appear in Figure 4-6. The first pivot table shows the default sort for a pivot table:
Customers are arranged alphabetically, starting with Adaept, Calleia, and so on.

In the second pivot table, the report is sorted in descending sequence by Total Revenue. This pivot
table was sorted by selecting cell E3 and choosing the ZA icon in the Data tab of the ribbon. Although
that sounds like a regular sort, it is better. When you sort inside a pivot table, Excel sets up a rule that
will be used after you make additional changes to the pivot table.

Chapter 4 Grouping, sorting, and filtering pivot data 79


FIGURE 4-6 When you override the default sort, Excel remembers the sort as additional fields are added.

The pivot table in columns G:H shows what happens after you add Sector as a new outer row field.
Within each sector, the pivot table continues to sort the data in descending order by revenue. Within
Consulting, Surten Excel appears first, with $750K, followed by NetCom, with $614K.

You could remove Customer from the pivot table, do more adjustments, and then add Customer
back to the column area, and Excel would remember that the customers should be presented from
high to low.

If you could see the entire pivot table in G3:H35 in Figure 4-6, you would notice that the sectors are
sorted alphabetically. It might make more sense, though, to put the largest sectors at the top. The fol-
lowing tricks can be used for sorting an outer row field by revenue:

■■ You can select cell G4 and then use Collapse Field on the Analyze tab to hide the customer de-
tail. When you have only the sectors showing, select H4 and click ZA to sort descending. Excel
understands that you want to set up a sort rule for the Sector field.

■■ You can temporarily remove Customer from the pivot table, sort descending by revenue, and
then add Customer back.

■■ You can use More Sort Options, as described in the following paragraphs.

To sort the Sector field, you should open the drop-down menu for the Sector field. Hover over Sec-
tor in the top of the PivotTable Fields list, and click the drop-down arrow that appears (see Figure 4-7).
Or, if your pivot table is shown in Tabular layout or Outline layout, you can simply open the drop-down
arrow in cell G3.

Inside the drop-down menu, choose More Sort Options to open the Sort (Sector) dialog box. In this
dialog box, you can choose to sort the Sector field in Descending order by Total $ (see Figure 4-8).

80 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-7 For explicit control over sort order, open this drop-down menu.

FIGURE 4-8 Choose to sort Sector based on the Total $ field.

The Sort (Sector) dialog box shown in Figure 4-8 includes a More Options button in the lower left. If
you click this button, you arrive at the More Sort Options dialog box, in which you can specify a custom
list to be used for the first key sort order. You can also specify that the sorting should be based on a
column other than Grand Total.

In Figure 4-10, the pivot table includes Product in the column area. If you wanted to sort the cus-
tomers based on total gadget revenue instead of total revenue, for example, you could do so with the
More Sort Options dialog box. Here are the steps:

1. Open the Customer heading drop-down menu in B4.

2. Choose More Sort Options.

Chapter 4 Grouping, sorting, and filtering pivot data 81


3. In the Sort (Customer) dialog box, choose More Options.

4. In the More Sort Options (Customer) dialog box, choose the Sort By Values In Selected Column
option (see Figure 4-9).

5. Click in the reference box and then click cell D5. Note that you cannot click the Gadget heading
in D4; you have to choose one of the Gadget value cells.

6. Click OK twice to return to the pivot table.

FIGURE 4-9 Using More Sort Options, you can sort by a specific pivot field item.

If your pivot table has only one field in the Rows area, you can set up the “Sort by Doodads” rule by
doing a simple sort using the Data tab. Select any cell in B5:B30 and choose Data, ZA. The pivot table
will be sorted with the largest Doodads customers at the top (see Figure 4-10). Note that you cannot
sort from the Doodads heading in B4. Sorting from there will sort the product columns by revenue.

FIGURE 4-10 Sort from cell E5 to sort by Doodads.

Using a manual sort sequence


The Sort dialog box offers something called a manual sort. Rather than using the dialog box, you can
invoke a manual sort in a surprising way.

Note that the products in Figure 4-10 are in the following order: Doodads, Gadget, Gizmo, and
Widget. It appears that the Doodads product line is a minor product line and probably would not fall
first in the product list.

82 Chapter 4 Grouping, sorting, and filtering pivot data


Place the cell pointer in cell E4 and type the word Doodads. When you press Enter, Excel figures out
that you want to move the Doodads column to be last. All the values for this product line move from
column B to column E. The values for the remaining products shift to the left.

One unintended consequence is that the customers re-sort based on the product that moved to
column B: Gadget. This is because the “Sort by Doodads” rule was actually a “Sort by whatever is in
column B” rule.

In Figure 4-11, note the numbers in row 17 and compare them to the numbers in row 5 in Figure 4-10.
The values followed the change in headings.

This behavior is completely unintuitive. You should never try this behavior with a regular (non–pivot
table) data set in Excel. You would never expect Excel to change the data sequence just by moving the
labels. Figure 4-11 shows the pivot table after a new column heading has been typed in cell E4.

FIGURE 4-11 Simply type a heading in E4 to rearrange the columns.

If you prefer to use the mouse, you can drag and drop the column heading to a new location. Select
a column heading. Hover over the edge of the active cell border until the mouse changes to a four-
headed arrow. Drag the cell to a new location, as shown in Figure 4-12. When you release the mouse, all
the value settings move to the new column.

FIGURE 4-12 Use drag and drop to move a column to a new position.

Chapter 4 Grouping, sorting, and filtering pivot data 83


Caution After you use a manual sort, any new products you add to the data source are
automatically added to the end of the list rather than appearing alphabetically.

Using a custom list for sorting


Another way to permanently change the order of items along a dimension is to set up a custom list.
All future pivot tables created on your computer will automatically respect the order of the items in a
custom list.

The pivot table at the top of Figure 4-13 includes weekday names. The weekday names were added
to the original data set by using =TEXT(F2,"DDD") and copying down. Excel automatically puts Sunday
first and Saturday last, even though this is not the alphabetical sequence of these words. This happens
because Excel ships with four custom lists to control the days of the week, months of the year, and the
three-letter abbreviations for both.

FIGURE 4-13 The weekday names in B4:H4 follow the order specified in the Custom Lists dialog box.

84 Chapter 4 Grouping, sorting, and filtering pivot data


You can define your own custom list to control the sort order of pivot tables. Follow these steps to
set up a custom list:

1. In an out-of-the-way section of the worksheet, type the products in their proper sequence.
Type one product per cell, going down a column.

2. Select the cells containing the list of regions in the proper sequence.

3. Click the File tab and select Options.

4. Select the Advanced category in the left navigation bar. Scroll down to the General group and
click the Edit Custom Lists button. In the Custom Lists dialog box, your selection address is
entered in the Import text box, as shown in Figure 4-13.

5. Click Import to bring the products in as a new list.

6. Click OK to close the Custom Lists dialog box, and then click OK to close the Excel Options
dialog box.

The custom list is now stored on your computer and is available for all future Excel sessions. All
future pivot tables will automatically show the product field in the order specified in the custom list.
Figure 4-14 shows a new pivot table created after the custom list was set up.

FIGURE 4-14 After you define a custom list, all future pivot tables will follow the order in the list.

To sort an existing pivot table by the newly defined custom list, follow these steps:

1. Open the Product header drop-down menu and choose More Sort Options.

2. In the Sort (Product) dialog box, choose More Options.

3. In the More Sort Options (Product) dialog box, clear the AutoSort check box.

4. As shown in Figure 4-15, in the More Sort Options (Product) dialog box, open the First Key Sort
Order drop-down menu and select the custom list with your product names.

5. Click OK twice.

Chapter 4 Grouping, sorting, and filtering pivot data 85


FIGURE 4-15 Choose to sort by the custom list.

Caution Items in a custom list will automatically sort to the top of all future pivot tables.
If you have a pivot table of people using their first names, people with names like Jan, May,
and April will automatically appear before other names. Names that appear in any list,
even across several custom lists will sort in the wrong sequence. To turn off this behavior
for one pivot table: right-click one cell in the pivot table and choose PivotTable options. On
the Totals & Filters tab, unselect Use Custom Lists When Sorting. If you want to turn this off
for all pivot tables, change the Pivot Table Defaults using File, Options, Data, Edit Default
Layout, PivotTable Options.

Filtering a pivot table: an overview


Excel 2019 provides dozens of ways to filter a pivot table. Figure 4-16 shows some of the filters available.
These methods, and the best way to use each one, are discussed in the following sections.

86 Chapter 4 Grouping, sorting, and filtering pivot data


Report Filter Row Filter
Value Filter Column Filter Timeline Slicer

Check boxes Search Box Top 10 Filter

FIGURE 4-16 This figure shows a fraction of the available filtering choices.

There are four ways to filter a pivot table, as shown in Figure 4-16:

■■ The Date Timeline filter in G4:H10 was introduced in Excel 2013.

■■ The Market filter in G12:H19 is an example of the slicer introduced in Excel 2010.

■■ A drop-down menu in B1 offers what were known as page filters in Excel 2003, report filters in
Excel 2010, and now simply filters.

■■ Cell G4 offers the top-secret AutoFilter location.

■■ Drop-down menus in A4 and B3 lead to even more filters.

■■ You see the traditional check box filters for each pivot item.

■■ A Search box filter was introduced in Excel 2010.

■■ A flyout menu has Label filters.

■■ Depending on the field type, you might see a Value Filters flyout menu, including the powerful
Top 10 filter, which can do Top 10, Bottom 5, Bottom 3%, Top $8 Million, and more.

■■ Depending on the field type, you might see a Date Filters flyout menu, with 37 virtual filters
such as Next Month, Last Year, and Year to Date.

Chapter 4 Grouping, sorting, and filtering pivot data 87


Using filters for row and column fields
If you have a field (or fields) in the row or column area of a pivot table, a drop-down menu with filtering
choices appears on the header cell for that field. In Figure 4-16, a Customer drop-down menu appears
in A4, and a Product drop-down menu appears in B3. The pivot table in that figure is using Tabular
layout. If your pivot tables use Compact layout, you see a drop-down menu on the cell with Row Labels
or Column Labels.

If you have multiple row fields, it is just as easy to sort using the invisible drop-down menus that ap-
pear when you hover over a field in the top of the PivotTable Fields list.

Filtering using the check boxes


You might have a few annoying products appear in a pivot table. In the present example, the Doodads
product line is a specialty product with very little sales. It might be an old legacy product that is out of
line, but it still gets an occasional order from the scrap bin. Every company seems to have these orphan
sales that no one really wants to see.

The check box filter provides an easy way to hide these items. Open the Product drop-down menu
and clear the Doodads check box. The product is hidden from view (see Figure 4-17) .

FIGURE 4-17 Open the Product filter and clear the Doodads check box.

What if you need to clear hundreds of items’ check boxes in order to leave only a few items se-
lected? You can toggle all items off or on by using the Select All check box at the top of the list. You can
then select the few items that you want to show in the pivot table.

In Figure 4-18, Select All turned off all customers and then two clicks reselected Excel4Apps and
F-Keys Ltd.

88 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-18 Use Select All to toggle all items off or on.

The check boxes work great in this tiny data set with 26 customers. In real life, with 500 customers in
the list, it will not be this easy to filter your data set by using the check boxes.

Filtering using the search box


When you have hundreds of customers, the search box can be a great timesaver. In Figure 4-19, the da-
tabase includes consultants, trainers, and other companies. If you want to narrow the list to companies
with Excel or spreadsheet in their name, you can follow these steps:

1. Open the Customer drop-down menu.

2. Type Excel in the search box (see Figure 4-19).

FIGURE 4-19 Select the results of the first search.

3. By default, Select All Search Results is selected. Click OK.

4. Open the Customer drop-down menu again.

5. Type spreadsheet in the search box.

Chapter 4 Grouping, sorting, and filtering pivot data 89


6. Choose Add Current Selection to Filter, as shown in Figure 4-20. Click OK.

FIGURE 4-20 For the second search, add these results to the existing filter.

You now have all customers with either Excel or spreadsheet in the name.

Caution Filters applied with the search box are single-use filters. If you add more data to
the underlying data and refresh the pivot table, this filter will not be reevaluated.
If you need to reapply the filter, it would be better to use the Label filters as discussed in the
following section. Label filters would work to find every customer with Excel in the name. It
would not work to find “Excel or spreadsheet.”

Filtering using the Label Filters option


The search box isn’t perfect. What if you want to find all the Lotus 1-2-3 consultants and turn those
off? There is no Select Everything Except These Results choice. Nor is there a Toggle All Filter Choices
choice. However, the Label Filters option enables you to handle queries such as “select all customers
that do not contain ‘Lotus.’”

Text fields offer a flyout menu called Label Filters. To filter out all of the Insurance customers, you
can apply a Does Not Contain filter (see Figure 4-21). In the next dialog box, you can specify that you
want customers that do not contain Excel, Exc, or Exc* (see Figure 4-22).

FIGURE 4-21 Choose Label Filters, Does Not Contain.

90 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-22 Specify to exclude customers containing Excel.

Note that label filters are not additive. You can only apply one label filter at a time. If you take the
data in Figure 4-21 and apply a new label filter of between D and Fzzz, some Excel customers that were
filtered out in Figure 4-22 come back, as shown in Figure 4-23.

FIGURE 4-23 Note that a second label filter does not get added to the previous filter. Excel is back in.

Filtering a Label column using information in a Values column


The Value Filters flyout menu enables you to filter customers based on information in the Values col-
umns. Perhaps you want to see customers who had between $20,000 and $30,000 of revenue. You can
use the Customer heading drop-down menu to control this. Here’s how:

1. Open the Customer drop-down menu.

2. Choose Label Filters.

3. Choose Between (see Figure 4-24).

4. Type the values 20000 and 30000, as shown in Figure 4-25.

Chapter 4 Grouping, sorting, and filtering pivot data 91


FIGURE 4-24 Value Filters for the Customer column will look at values in the Revenue field.

FIGURE 4-25 Choose customers between 20000 and 30000, inclusive.

5. Click OK.

The results are inclusive; if a customer had exactly $20,000 or exactly $30,000, they are returned
along with the customers between $20,000 and $30,000.

Note Choosing a Value filter clears out any previous Label filters.

92 Chapter 4 Grouping, sorting, and filtering pivot data


Creating a top-five report using the Top 10 filter
One of the more interesting value filters is the Top 10 filter. If you are sending a report to the VP of
Sales, she is not going to want to see hundreds of pages of customers. One short summary with the top
customers is almost more than her attention span can handle. Here’s how to create it:

1. Go to the Customer drop-down menu and choose Value Filters, Top 10.

2. In the Top 10 Filter dialog box, which enables you to choose Top or Bottom, leave the setting at
the default of Top.

3. In the second field, enter any number of customers: 10, 5, 7, 12, or something else.

4. In the third drop-down menu on the dialog box, select from Items, Percent, and Sum. You could
ask for the top 10 items. You could ask for the top 80% of revenue (which the theory says should
be 20% of the customers). Or you could ask for enough customers to reach a sum of $5 million
(see Figure 4-26).

FIGURE 4-26 Create a report of the top five customers.

The $1,758,220 total shown in cell B9 in Figure 4-26 is the revenue of only the visible customers. It
does not include the revenue for the remaining customers. You might want to show the grand total of
all customers at the bottom of the list. You have a few options:

■■ A setting on the Design tab, under the Subtotals drop-down menu, enables you to include
values from filtered items in the totals. This option is available only for OLAP data sets and data
sets where you choose Add This Data To The Data Model when creating the pivot table.

Note See Chapter 10, “Unlocking features with the Data Model and Power Pivot,” for more
information on working with Power Pivot.

Chapter 4 Grouping, sorting, and filtering pivot data 93


■■ You can remove the grand total from the pivot table in Figure 4-27 and build another one-row
pivot table just below this data set. Hide the heading row from the second pivot table, and you
will appear to have the true grand total at the bottom of the pivot table.

■■ If you select the blank cell to the right of the last heading (C3 in Figure 4-26), you can turn on
the filter on the Data tab. This filter is not designed for pivot tables and is usually grayed out.
After you’ve added the regular filters, open the drop-down menu in B3. Choose Top 10 Filter
and ask for the top six items, as shown in Figure 4-27. This returns the top five customers and
the grand total from the data set.

Caution Be aware that this method is taking advantage of a bug in Excel. Normally, the
Filter found on the Data tab is not allowed in a pivot table. If you use this method and later
refresh the pivot table, the Excel team will not update the filter for you. As far as they know,
the option to filter is grayed out when you are in a pivot table.

FIGURE 4-27 You are taking advantage of a hole in the fabric of Excel to apply a regular AutoFilter to a pivot table.

Filtering using the Date filters in the Label drop-down menu


If your label field contains all dates, Excel replaces the Label Filter flyout with a Date Filters flyout. These
filters offer many virtual filters, such as Next Week, This Month, Last Quarter, and so on (see Figure
4-28).

94 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-28 The Date Filters menu offers various virtual date periods.

If you choose Equals, Before, After, or Between, you can specify a date or a range of dates.

Options for the current, past, or next day, week, month, quarter, or year occupy 15 options. Com-
bined with Year To Date, these options change day after day. You can pivot a list of projects by due date
and always see the projects that are due in the next week by using this option. When you open the
workbook on another day, the report recalculates.

Tip A week runs from Sunday through Saturday. If you select Next Week, the report always
shows a period from the next Sunday through the following Saturday.

When you select All Dates In The Period, a new flyout menu offers options such as Each Month and
Each Quarter.

Chapter 4 Grouping, sorting, and filtering pivot data 95


Caution If your date field contains dates and times, the Date Filters might not work as
expected. You might ask for dates equal to 4/15/2022, and Excel will say that no records are
found. The problem is that 6:00 p.m. on 4/15/2022 is stored internally as 44666.75, with the
“.75” representing the 18 hours elapsed in the day between midnight and 6:00 p.m. If you
want to return all records that happened at any point on April 15, select the Whole Days
check box in the Date Filter dialog box.

Filtering using the Filters area


Pivot table veterans remember the old Page area section of a pivot table. This area has been renamed
the Filters area and still operates basically the same as in legacy versions of Excel. Microsoft did add the
capability to select multiple items from the Filters area. Although the Filters area is not as showy as slic-
ers, it is still useful when you need to replicate your pivot table for every customer.

Adding fields to the Filters area


The pivot table in Figure 4-29 is a perfect ad-hoc reporting tool to give to a high-level executive. He
can use the drop-down menus in B1:B4 and E1:E4 to find revenue quickly for any combination of sector,
region, market, rep, customer, product, date, or weekday. This is a typical use of filters.

FIGURE 4-29 With multiple fields in the Filters area, this pivot table can answer many ad-hoc queries.

To set up the report, drag Revenue and Cost to the Values area and then drag as many fields as
desired to the Filters area.

If you add many fields to the Filters area, you might want to use one of the obscure pivot table op-
tions settings. Click Options on the Analyze tab. On the Layout & Format tab of the PivotTable Options
dialog box, change Report Filter Fields per Column from 0 to a positive number. Excel rearranges the
Filter fields into multiple columns. Figure 4-29 shows the filters with four fields per column. You can
also change Down, Then Over to Over, Then Down to rearrange the sequence of the Filter fields.

Choosing one item from a filter


To filter the pivot table, click any drop-down menu in the Filters area of the pivot table. The drop-down
menu always starts with (All) but then lists the complete unique set of items available in that field.

96 Chapter 4 Grouping, sorting, and filtering pivot data


Choosing multiple items from a filter
At the bottom of the Filters drop-down menu is a check box labeled Select Multiple Items. If you select
it, Excel adds a check box next to each item in the drop-down menu. This enables you to select multiple
items from the list.

In Figure 4-30, the pivot table is filtered to show revenue from multiple sectors, but it is impossible
to tell which sectors are included.

FIGURE 4-30 You can select multiple items, but after the Filter drop-down menu closes, you cannot tell which
items were selected.

Tip Selecting multiple items from the filter leads to a situation where the person reading
the report will not know which items are included. Slicers solve this problem.

Replicating a pivot table report for each item in a filter


Although slicers are now the darlings of the pivot table report, the good old-fashioned report filter can
still do one trick that slicers cannot do. Say you have created a report that you would like to share with
the industry managers. You have a report showing customers with revenue and profit. You would like
each industry manager to see only the customers in their area of responsibility.

Follow these steps to quickly replicate the pivot table:

1. Make sure the formatting in the pivot table looks good before you start. You are about to make
several copies of the pivot table, and you don’t want to format each worksheet in the work-
book, so double-check the number formatting and headings now.

2. Add the Sector field to the Filters area. Leave the Sector filter set to (All).

3. Select one cell in the pivot table so that you can see the Analyze tab in the ribbon.

4. Find the Options button in the left side of the Analyze tab. Next to the Options tab is a drop-
down menu. Don’t click the big Options button. Instead, open the drop-down menu (see Figure
4-31).

Chapter 4 Grouping, sorting, and filtering pivot data 97


FIGURE 4-31 Click the tiny drop-down arrow next to the Options button.

5. Choose Show Report Filter Pages. In the Show Report Filter Pages dialog box, you see a list of
all the fields in the report area. Because this pivot table has only the Sector field, this is the only
choice (see Figure 4-32).

FIGURE 4-32 Select the field by which to replicate the report.

6. Click OK and stand back.

Excel inserts a new worksheet for every item in the Sector field. On the first new worksheet, Excel
chooses the first sector as the filter value for that sheet. Excel renames the worksheet to match the
sector. Figure 4-33 shows the new Consulting worksheet, with neighboring tabs that contain Museums,
Retail, Training, and Utilities.

Tip If the underlying data changes, you can refresh all of the Sector worksheets by using
Refresh on one Sector pivot table. After you refresh the Consulting worksheet, all the pivot
tables refresh.

98 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-33 Excel quickly adds one page per sector.

Filtering using slicers and timelines


Slicers are graphical versions of the Report Filter fields. Rather than hiding the items selected in the
filter drop-down menu behind a heading such as (Multiple Items), the slicer provides a large array of
buttons that show at a glance which items are included or excluded.

To add slicers, click the Insert Slicer icon on the Analyze tab. Excel displays the Insert Slicers dialog
box. Choose all the fields for which you want to create graphical filters, as shown in Figure 4-34.

FIGURE 4-34 Choose fields for slicers.

Chapter 4 Grouping, sorting, and filtering pivot data 99


Initially, Excel chooses one-column slicers of similar color in a cascade arrangement (see Figure
4-35). However, you can change these settings by selecting a slicer and using the Slicer Tools Options
tab in the ribbon.

FIGURE 4-35 The slicers appear with one column each.

You can add more columns to a slicer. If you have to show 50 two-letter state abbreviations, that
will look much better as 5 rows of 10 columns than as 50 rows of 1 column. Click the slicer to get access
to the Slicer Tools Analyze tab. Use the Columns spin button to increase the number of columns in
the slicer. Use the resize handles in the slicer to make the slicer wider or shorter. To add visual interest,
choose a different color from the Slicer Styles gallery for each field.

After formatting the slicers, arrange them in a blank section of the worksheet, as shown in Figure 4-36.

FIGURE 4-36 After formatting, your slicers might fit on a single screen.

100 Chapter 4 Grouping, sorting, and filtering pivot data


Three colors might appear in a slicer. The dark color indicates items that are selected. Gray boxes
often mean the item has no records because of other slicers. White boxes indicate items that are not
selected.

Note that you can control the heading for the slicer and the order of items in the slicer by using the
Slicer Settings icon on the Slicer Tools Options tab of the ribbon. Just as you can define a new pivot
table style, you can also right-click an existing slicer style and choose Duplicate. You can change the
font, colors, and so on.

A new icon debuted in Excel 2016, in the top bar of the slicer. The icon appears as three check marks.
When you select this icon, you can select multiple items from the slicer without having to hold down
the Ctrl key.

Using timelines to filter by date


After slicers were introduced in Excel 2010, there was some feedback that using slicers was not an ideal
way to deal with date fields. You might end up adding some fields to your original data set to show
(perhaps) a decade and then use the group feature for year, quarter, and month. You would end up
with a whole bunch of slicers all trying to select a time period, as shown in Figure 4-37.

FIGURE 4-37 Four different slicers are necessary to filter by date.

For Excel 2013, Microsoft introduced a new kind of filter called a Timeline slicer. To use one, select
one cell in your pivot table and choose Insert Timeline from the Analyze tab. Timeline slicers can only
apply to fields that contain dates. Excel gives you a list of date fields to choose from, although in most
cases, there is only one date field from which to choose.

Figure 4-38 shows a Timeline slicer. Perhaps the best part of a Timeline slicer is the drop-down
menu that lets you repurpose the timeline for days, months, quarters, or years. This works even if you
have not grouped your daily dates up to months, quarters, or years.

Chapter 4 Grouping, sorting, and filtering pivot data 101


FIGURE 4-38 A single Timeline slicer can filter your pivot table by month, quarter, year, or day.

Driving multiple pivot tables from one set of slicers


Chapter 12, “Enhancing pivot table reports with macros,” includes a tiny macro that lets you drive two
pivot tables with one set of filters. This has historically been difficult to do unless you used a macro.

Now, one set of slicers or timelines can be used to drive multiple pivot tables or pivot charts. In Fig-
ure 4-39, the Market slicer is driving three elements. It drives the pivot table in the top left with revenue
by sector and product. It drives two pivot tables created for the top-right and lower-left charts.

FIGURE 4-39 Three pivot elements controlled by the same slicer.

102 Chapter 4 Grouping, sorting, and filtering pivot data


Note For more information about how to create pivot charts, refer to Chapter 6, “Using
pivot charts and other visualizations.”

The following steps show you how to create three pivot tables that are tied to a single slicer:

1. Create your first pivot table.

2. Select a cell in the first pivot table. Choose Insert Slicer. Choose one or more fields to be used as
a slicer. Alternatively, insert a Timeline slicer for a date field.

3. Select the entire pivot table.

4. Copy with Ctrl+C or the Copy command.

5. Select a new blank area of the worksheet.

6. Paste. Excel creates a second pivot table that shares the pivot cache with the first pivot table. In
order for one slicer to run multiple pivot tables, they must share the same pivot cache.

7. Change the fields in the second pivot table to show some other interesting analysis.

8. Repeat steps 3–7 to create a third copy of the pivot table.

The preceding steps require you to create the slicer after you create the first pivot table but before
you make copies of the pivot table.

If you already have several existing pivot tables and need to hook them up to the same slicer, follow
these steps:

1. Click the slicer to select it. When the slicer is selected, the Slicer Tools Design tab of the ribbon
appears.

2. Select the Slicer Tools Design tab and choose Report Connections. Excel displays the Report
Connections (Market) dialog box. Initially, only the first pivot table is selected.

3. As shown in Figure 4-40, choose the other pivot tables in the dialog box and click OK.

FIGURE 4-40 Choose to hook this slicer up to the other pivot tables.

4. If you created multiple slicers and/or timelines, repeat steps 1 through 3 for the other slicers.

Chapter 4 Grouping, sorting, and filtering pivot data 103


The result is a dashboard in which all of the pivot tables and pivot charts update in response to
selections made in the slicer (see Figure 4-41).

FIGURE 4-41 All of the pivot charts and pivot tables update when you choose from the slicer.

Tip The worksheet in Figure 4-41 would be a perfect worksheet to publish to SharePoint
or to your OneDrive. You can share the workbook with coworkers and allow them to interact
with the slicers. They won’t need to worry about the underlying data or enter any numbers;
they can just click on the slicer to see the reports update.

Grouping and creating hierarchies in a pivot table


Pivot tables have the ability to do roll-ups in memory. You can roll daily dates up to weeks, months,
quarters, or years. Time can roll up to minutes or hours. Numbers can be grouped into equal-size buck-
ets. Text entries can be grouped into territories.

You can use the Power Pivot grid to define a hierarchy so you can quickly drill down on a pivot table or
chart.

Grouping numeric fields


The Grouping dialog box for numeric fields enables you to group items into equal ranges. This can be
useful for creating frequency distributions. The pivot table in Figure 4-42 is quite the opposite of any-
thing you’ve seen so far in this book. The numeric field—Revenue—is in the Rows area. A text field—

104 Chapter 4 Grouping, sorting, and filtering pivot data


Customer—is in the Values area. When you put a text field in the Values area, you get a count of how
many records match the criteria. In its present state, this pivot table is not that fascinating; it is telling
you that exactly one record in the database has a total revenue of $23,990.

FIGURE 4-42 Nothing interesting here—just lots of order totals that appear exactly one time in the database.

Select one number in column A of the pivot table. Select Group Field from the Analyze tab of the
ribbon. Because this field is not a date field, the Grouping dialog box offers fields for Starting At, End-
ing At, and By. As shown in Figure 4-43, you can choose to show amounts from 0 to 30,000 in groups of
5,000.

FIGURE 4-43 Create a frequency distribution by grouping the order size into $5,000 buckets.

After grouping the order size into buckets, you might want to add additional fields, such as Revenue
and % Of Revenue shown as a percentage of the total.

Note The grouping dialog box requires all groups to be the same size. I have heard ques-
tions where people want to group into 0–100K, 200K–500K, but this is not possible using the
Grouping feature. You would have to add a new column to the source data in order to create
these groupings.

Chapter 4 Grouping, sorting, and filtering pivot data 105


Case Study: Grouping text fields for redistricting
Say that you get a call from the VP of Sales. The Sales Department is secretly considering
a massive reorganization of the sales regions. The VP would like to see a report showing
revenue after redistricting. You have been around long enough to know that the proposed
regions will change several times before the reorganization happens, so you are not willing
to change the Region field in your source data quite yet.
First, build a report showing revenue by market. The VP of Sales is proposing eliminating
two regional managers and redistricting the country into three super-regions. While hold-
ing down the Ctrl key, highlight the five regions that will make up the new West region.
Figure 4-44 shows the pivot table before the first group is created.

FIGURE 4-44 Use the Ctrl key to select the noncontiguous cells that make up the new region.

From the Analyze tab, click Group Selection. Excel adds a new field called Market2. The five
selected regions are arbitrarily rolled up to a new territory called Group1. In Figure 4.45, the
Group1 label in A4 is the first item in the new Market2 virtual field. The other items in the
Market2 field includee Atlanta in A10, Charlotte in A12 and so on. The similar items in A11 and
A13 are items in the original Market field. Use care while holding down the Ctrl key to select
the unbolded markets for the South region: Atlanta in row 11, Charlotte in row 13, Huntsville
in row 11, and Louisville in row 23...
Click Group Selection to group the markets in the proposed Southeast region. Repeat to
group the remaining regions into the proposed Northeast region. Figure 4-46 shows what
it looks like when you have grouped the markets into new regions. Five things need further

106 Chapter 4 Grouping, sorting, and filtering pivot data


adjustment: the names of Group1, Group2, Group3, and Market2, and the lack of subtotals
for the outer row field.

FIGURE 4-45 The first super-region is arbitrarily called Group1.

FIGURE 4-46 The markets are grouped, but you have to do some cleanup.

Cleaning up the report takes only a few moments:


1. Select cell A4. Type West to replace the arbitrary name Group1.

2. Select cell A10. Type Southeast to replace the arbitrary name Group2.

Chapter 4 Grouping, sorting, and filtering pivot data 107


3. Select A15. Type Northeast to replace Group3.

4. Select any outer heading in A4, A10, or A15. Click Field Settings on the Analyze tab.

5. In the Field Settings dialog box, replace the Custom Name of Market2 with Proposed
Region. Also, in the Field Settings dialog box, change the Subtotals setting from None
to Automatic.

Figure 4-47 shows the pivot table that results, which is ready for the VP of Sales.

FIGURE 4-47 It is now easy to see that these regions are heavily unbalanced.

You can probably predict that the Sales Department needs to shuffle markets to balance the
regions. To go back to the original regions, select any Proposed Region cell in A4, A10, or
A15 and choose Ungroup. You can then start over, grouping regions in new combinations.

Grouping date fields manually


Excel provides a straightforward way to group date fields. Select any date cell in your pivot table. On
the Analyze tab, click Group Field in the Group option.

When your field contains date information, the date version of the Grouping dialog box appears. By
default, the Months option is selected. You have choices to group by Seconds, Minutes, Hours, Days,
Months, Quarters, and Years. It is possible—and usually advisable—to select more than one field in the
Grouping dialog box. In this case, select Months and Years, as shown in Figure 4-48.

There are several interesting points to note about the resulting pivot table. First, notice that the
Years field has been added to the PivotTable Fields list. Don’t let this fool you. Your source data is not
changed to include the new field. Instead, this field is now part of your pivot cache in memory.

108 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-48 Business users of Excel usually group by months (or quarters) and years.

Another interesting point is that, by default, the Years field is automatically added to the same area
as the original date field in the pivot table layout, as shown in Figure 4-49. Although this happens au-
tomatically, you are free to pivot months and years onto the opposite axis of the report. This is a quick
way to create a year-over-year sales report.

FIGURE 4-49 By default, Excel adds the new grouped date field to your pivot table layout.

Chapter 4 Grouping, sorting, and filtering pivot data 109


Including years when grouping by months
Although this point is not immediately obvious, it is important to understand that if you group a date
field by month, you also need to include the year in the grouping. If your data set includes January
2024 and January 2025, selecting only months in the Grouping dialog box will result in both January
2024 and January 2025 being combined into a single row called January (see Figure 4-50).

FIGURE 4-50 If you fail to include the Year field in the grouping, the report mixes sales from last January and this
January into a single row called January.

Grouping date fields by week


The Grouping dialog box offers choices to group by second, minute, hour, day, month, quarter, and
year. It is also possible to group on a weekly or biweekly basis.

The first step is to find either a paper calendar or an electronic calendar, such as the Calendar fea-
ture in Outlook, for the year in question. If your data starts on January 1, 2024, it is helpful to know that
January 1 is a Monday that year. You need to decide if weeks should start on Sunday or Monday or any
other day. For example, you can check the paper or electronic calendar to learn that the nearest start-
ing Sunday is December 31, 2023.

Select any date heading in your pivot table. Then select Group Field from the Analyze tab. In the
Grouping dialog box, clear all the By options and select only the Days field. This enables the spin but-
ton for Number of Days. To produce a report by week, increase the number of days from 1 to 7.

Next, you need to set up the Starting At date. If you were to accept the default of starting at Janu-
ary 1, 2024, all your weekly periods would run from Monday through Sunday. By checking a calendar
before you begin, you know that you want the first group to start on December 31, 2023, to have weeks
that run Sunday through Monday. Figure 4-51 shows the settings in the Grouping dialog box and the
resulting report.

110 Chapter 4 Grouping, sorting, and filtering pivot data


Start date

Choose only Days

Number of days

FIGURE 4-51 Group dates up to weekly periods.

Caution If you choose to group by week, none of the other grouping options can be se-
lected. You cannot group this or any field by month, quarter, or year. You cannot add calcu-
lated items to the pivot table.

AutoGrouping pivot table dates


Excel 2016 introduced an AutoGroup feature for dates. If you dragged a date field to a pivot table, Excel
would quickly add date rollups and define a hierarchy for the dates.

The feature was turned on by default, and the only way to turn it off was a change in the Registry.

I love the concept of teaching people that daily dates can easily be rolled up. But for the people who
needed to report daily dates, the AutoGroup was inconsistent and confusing. The logic used to choose
which rollups would be present would sometimes leave out daily dates from the hierarchy.

Today, Excel 2019 will not automatically AutoGroup. You can choose to allow the AutoGroup if you
loved this feature. Go To File, Options, Data, and deselect Disable Automatic Grouping Of Date/Time
Columns In Pivot Tables.

Understanding how Excel decides what to AutoGroup


If you have daily dates that include an entire year or that fall in two or more years, Excel 2019 groups
the daily dates to include years, quarters, and months. If you need to report by daily dates, you will
have to select any date cell, choose Group Field, and add Days. Note that the rules change if your data
is in the Data Model. In that case, AutoGroup would include daily dates as well.

Chapter 4 Grouping, sorting, and filtering pivot data 111


If you have daily dates that fall within one calendar year and span more than one month, Excel
groups the daily dates to month and includes daily dates.

Caution If your company is closed on New Year’s Day and you have no sales on January 1,
a data set that stretches from January 2 to December 31 will fit the “less than a full year” case
and will include months and daily dates.

If your data contains times that do not cross over midnight, you get hours, minutes, and seconds. If
the times span more than one day, you get days, hours, minutes, and seconds.

Using AutoGroup
Say that you have a column in your data set with daily dates that span two years. When you add this
Date field to the Rows area of your pivot table, you will see rows for each year instead of hundreds of
daily dates. If your pivot table is in Tabular layout, you will see extra columns for Quarter and Date that
appear to have no data (see Figure 4-52).

When you look in the Pivot Table Fields list, you see that the Rows area automatically includes three
fields: Years, Quarter, and Date. All three of these are virtual fields created by grouping the daily dates
up to months, quarters, and years.

The three fields are added to either the Rows area or the Columns area. However, only the highest
level of the date field will be showing. To see the quarters and years, click one cell that contains a year
and then click the Expand button in the Analyze tab of the ribbon (see Figure 4-53). To see months,
select a cell containing a quarter and click the Expand button again (see Figure 4-54).

FIGURE 4-52 Excel can automatically groups two years’ worth of daily dates up to months, quarters, and years

112 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-53 Use Expand Field to show the quarters.

FIGURE 4-54 Expand Field again to show the monthly data.

Creating an easy year-over-year report


You can use date grouping to easily create a year-over-year report. You can either manually group the
dates to years or use the AutoGroup.

Follow these steps:

1. Create a pivot table with Years in the Columns area and Months in the Rows area. Drag Revenue
to the Values area. By default, the pivot table will offer a Grand Total column, as shown in Figure
4-55.

2. Right-click the Grand Total heading and choose Remove Grand Total.

3. Drag Revenue a second time to the Values area.

4. In the Columns area, drag Years so it is below Values. You will have the pivot table shown in
Figure 4-56.

Chapter 4 Grouping, sorting, and filtering pivot data 113


FIGURE 4-55 Group daily dates to months and years. Drag Years to go across the report.

FIGURE 4-56 This year and last year appear twice across the top of the report.

5. Double-click the Sum of Revenue2 heading in cell D4 to display the Value Field Settings dialog
box.

6. In the Value Field Settings dialog box, select the Show Values As tab. In the Show Values As
drop-down menu, choose % Difference From. In the Base Field list, choose Years. In the Base
Item, choose (Previous), as shown in Figure 4-57.

114 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-57 Change the second Revenue columns to percentage difference from the previous year.

7. Close the Value Field Settings dialog box. Column E will show the percentage change from the
first year to the last year. Column D will be blank because the pivot table has no data from 2023
to use to compare to 2024.

8. Hide column D.

9. Select the 2025 heading in E5. Press Ctrl+1 for Format Cells. On the Number tab, choose Cus-
tom. Type a format of ;;;"% Change".

You have a report showing year 1 versus year 2 and a percentage change. You can easily remove the
Months from column A and insert Region, Market, or Product to see the year-over-year change. Figure
4-58 shows a year-over-year report for Regions.

FIGURE 4-58 Once you have the year-over-year report set up, you can swap any field in to column A.

Chapter 4 Grouping, sorting, and filtering pivot data 115


Creating hierarchies
Back in Figures 4-53 through 4-55, you used the Expand Field to drill in to different date levels. If you
build your pivot table using the Data Model, you can use the Diagram View in Power Pivot to create a
formal hierarchy. Once you have a hierarchy in your pivot table, you can use the Drill Down and Drill Up
buttons that are perpetually grayed out in the ribbon.

Consider the pivot table and pivot chart shown in Figure 4-59. The pivot table is built using the Data
Model; when you choose Insert Pivot Table, make sure to choose Add This Data To The Data Model. The
pivot table has regions in the Rows area and Products in the Columns area. The pivot chart is showing a
stacked column chart.

FIGURE 4-59 A pivot table and a pivot chart without any hierarchy.

Follow these steps to add a hierarchy below Region:

1. Click the Manage icon in the Power Pivot tab of the ribbon.

2. On the Home tab of the Power Pivot for Excel window, click Diagram View.

3. Resize the Range table so you can see all the fields.

4. Click on the top field for the hierarchy: Region. Ctrl+click the remaining members of the hierar-
chy: Market and Rep.

5. Right-click on Region and choose Create Hierarchy (see Figure 4-60).

116 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-60 Select Region, Market, and Rep. Right-click and choose Create Hierarchy.

6. Hierarchy1 will appear at the bottom of the table. Right-click the name and choose Rename.
Type a meaningful name such as Geography (see Figure 4-61).

FIGURE 4-61 The hierarchy is shown at the bottom of the table.

7. Carefully review the sequence of the hierarchy. In Figure 4-61, Rep is appearing before Market.
This is incorrect. Right-click on Market and choose Move Up.

8. Close the Power Pivot window and return to Excel. After a brief pause, the PivotTable Fields list
will show the table name (Range), the hierarchy name (Geography), and something called More
Fields.

Chapter 4 Grouping, sorting, and filtering pivot data 117


9. Remove Region from the Rows area. Choose the Geography hierarchy from the PivotTable
Fields list. As shown in Figure 4-62, you have something very similar to Figure 4-59. However,
note that Drill Down is now enabled in the ribbon.

FIGURE 4-62 Plus signs appear next to each region. The Drill Down icon is enabled.

10. Select cell A7 for South. Click on Drill Down. The pivot table and pivot chart will change to show
the markets in the South region (see Figure 4-63).

You can keep using Drill Down or Drill Up to travel through the hierarchy.

118 Chapter 4 Grouping, sorting, and filtering pivot data


FIGURE 4-63 After drilling down on the South region, the markets in the South appear. The Drill Up icon is now
enabled.

Next steps
In Chapter 5, “Performing calculations in pivot tables,” you’ll learn how to use pivot table formulas to
add new virtual fields to a pivot table.

Chapter 4 Grouping, sorting, and filtering pivot data 119


Index

Symbols combining data sets, 297


custom maps, 290
% Difference From option (Value Field Settings custom shapes, 290
dialog box, Show Values As tab), 68-69 data cards (tooltips), 296
% Of option (Value Field Settings dialog box, Show filters, 296
Values As tab), 66 flat maps, 295-296
% Of Parent Column option (Value Field Settings geocoding data, 290-291
dialog box, Show Values As tab), 69 heat maps, 294
% Of Parent Row option (Value Field Settings hiding
dialog box, Show Values As tab), 69
legends, 296
% Of Parent Total option (Value Field Settings
panes, 296
dialog box, Show Values As tab), 69
labeling
% Of Total option (Value Field Settings dialog box,
data points, 294
Show Values As tab), 66
maps, 295
latitude, 290
legends
Numbers hiding, 296
3D Map, 289 resizing, 296
aerial photography maps, 295 longitude, 290
animating data over time, 297-298 navigating maps, 292-293
annotation (text boxes), 294, 299 pie charts, 294
bubble charts, 294 preparing data for, 289
column charts, 292, 296 region maps, 294

443
3D Map

relationships (table), 290 linked tables to Data Model, 279


resizing legends, 296 model fields to pivot tables, 383
store maps, using instead of globes (case numeric fields to Values area, 384
study), 299-302 rank number fields to pivot tables, 396-398
table relationships, 290 scrollbars to spreadsheets, 309-312
timelines, 298 tables to Data Model, 180, 279, 381
tours, creating, 298-299 add-ins (Power Query), 188
vantage point, moving, 293 Advanced Query Editor (Power Query), 195
video, creating, 299 aerial photography maps in 3D Map, 295
zooming in/out of maps, 293 Allington, Matt, 287
32-bit Excel analyzing OLAP pivot table data (what-if analysis),
Data Model and, 287 258-259
Power Pivot and, 287 animation in 3D Map, 297-298
annotation (text boxes) in 3D Map, 294, 299
applied steps (Power Query), 194-195, 276

A Areas section drop-downs (Field list), 78-79


arrow keys in formula creation, 286
Access (MS), creating pivot tables, 181-184 artificial intelligence. See Insights feature
ActiveX controls versus form controls, 307 AutoComplete tool (VBA), 326
adding auto date-grouping, 75
calculated columns in Power Pivot grid, AutoFiltering pivot tables, 401-404
281-282
AutoFit, column widths, 59
calculations to OLAP pivot tables, 250
AutoGroup, 330
columns
date groups, 344
calculated columns in Power Pivot grid,
determining AutoGroup criteria, 111
281-282
using, 112
to slicers, 100
year-over-year reports, creating, 113-115
with Power Query, 275-276
AutoShow (VBA), executive overviews of pivot
fields
tables, 365-367
model fields to pivot tables, 383
AutoSort, pivot table sort order, 347
numeric fields to Values area, 384
rank number fields to pivot tables,

B
396-398
to data areas, 332-333
to reports, 22-24 backward compatibility
functionality to recorded macros, 308-309 Check Compatibility tool, 7-9
layers to reports, 25 pivot tables and Excel, 7-8
Timeline slicer, 35

444
calculations

basic pivot table creation, 19 blank rows (layouts), 50, 56-57


adding bubble charts in 3D Map, 294
fields to reports, 22
layers to reports, 25
choosing report location, 20 C
classic pivot table layout, 26-27
data selection, 20 calculated columns, adding in Power Pivot grid,
281-282
fields
calculated fields, 286
adding to reports, 24
calculated data fields, 358-359
dragging/dropping in reports, 25-26
creating, 123-128
filters, creating, 27
DAX measures, using instead of calculated
Ideas feature, 29-30
fields (case study), 141-145
laying out reports, 22-24
defined, 121
deferring layout updates, 39-40
inserting into pivot tables, 124-125
starting over, 40
manually adding to data sources, 122-123
PivotTable Fields list, 21-22
rules specific to, 139-140
adding fields to tables, 24
summarizing next year’s forecast (case study),
dragging/dropping fields in tables,
129-133
25-26
calculated items, 286
rearranging tables, 25-26
changing solve order of, 147
Recommended PivotTables, 28-30
creating, 133-137
slicers
defined, 121
connecting to multiple pivot tables,
rules for, 145-146
32-33
calculated measures (OLAP), 250-253
standard slicers, 31-33
calculated members (OLAP), 250, 254-257
Timeline slicer, 34-35
calculations, 355, 384. See also measures
big data files, processing with Power Query,
273-275 adding to OLAP pivot tables, 250

blank cells calculated fields, 286

deleting from pivot tables, 346-347 calculated data fields, 358-359

filling creating, 123-128

in data area, 336 creating with formulas outside a pivot


table, 123, 124
in row area, 336
defined, 121
in data sources, 14
inserting into pivot tables, 124-125
in numeric columns, 24
manually adding to data sources,
replacing with zeros, 47-48
122-123

445
calculations

rules specific to, 139-140 case studies


summarizing next year’s forecast (case calculated fields, using DAX measures instead
study), 129-133 of, 141-145
using DAX measures instead of cal- converting live pivot tables to static values,
culated fields (case study), 141-145 54-55
calculated items, 359-361 data sources, cleaning up, 15-19
changing solve order of, 147 grouping text fields for redistricting, 106-108
creating, 133-137 interactive reports showing revenue by
defined, 121 product and time period (case study),
rules for, 145-146 creating, 157-161
calculating groups, 361-362 life after pivot tables, xxvii-xxviii, xxix
calculation functions, 356-358 life before pivot tables, xxiv-xxvi
cell references and, 139 market activity analysis, 35-36
constants and, 139 store maps, using instead of globes, 299-302
DAX measures, 139 summarizing next year’s forecast, 129-133
defined, 121 transposing data sets with Power Query,
using DAX measures instead of cal- 202-204
culated fields (case study), 141-145 categorizing columns with Power Pivot, 287
deleting, 146-147 cells
documenting, 148 blank cells
editing, 146-147 deleting from pivot tables, 346-347
grand total references, 139 filling in data area, 336
managing, 257-258 filling in row area, 336
multiple data fields, troubleshooting issues in data sources, 14
with, 355-356 in numeric columns, 24
named ranges and, 139 replacing with zeros, 47-48
OLAP pivot tables, managing calculations, calculations and cell references, 139
257-258 deleting cells, preventing errors, 336-337
operator precedence, 138 empty cells, filling in row fields, 393-396
Show Values As tab (Value Field Settings extracting from pivot tables based on pivot
dialog box), performing calculations caches, 232
with, 362-363 formatting in Office 365, 72
subtotal references, 139 inserting cells, preventing errors, 336-337
totals, referencing, 139 changing
VBA calculation options per Excel version, 364 default pivot table behaviors for future pivot
worksheet functions and, 139 tables, 392
field names, 49
pivot table names, 33

446
columns

previewing changes with Live Preview feature, columns


60 % Of Parent Column option (Value Field
solve order of calculated items, 147 Settings dialog box, Show Values As tab),
charts 69
bubble charts in 3D Map, 294 adding
column charts in 3D Map, 292 columns to slicers, 100
column charts in 3D Map, 296 columns with Power Query, 275-276
cross-filtering charts with Power BI Desktop, multiple subtotals to one field, 72
218 calculated columns, adding in Power Pivot
pie charts in 3D Map, 294 grid, 281-282
pivot charts categorizing columns with Power Pivot, 287
alternatives to, 161-165 column charts in 3D Map, 292, 296
creating, 150-153 Column From Examples feature (Power
defined, 149 Query), 275
formatting limitations, 156 empty columns in data sources, 14
interactive reports showing revenue filtering fields, 88
by product and time period (case groups, repeating as columns, 13
study), 157-161 headings, 11
pivot field buttons, 152-153, 160 hiding columns in Power Pivot, 287
pivot tables and, 154-156, 162 labels
x-axis, 155 filtering with Values column infor-
XY scatter charts, 164-165 mation, 91-92
y-axis, 155 splitting between two rows, 12
check boxes, filtering with, 88-89 manual sort sequences, 83-84
Check Compatibility tool, 7-9 multiple subtotals, adding to one field, 72
classic pivot table layout, 26-27 numeric columns, blank cells in, 24
cleaning up data sources (case study), 15-19 percentage change column for year-over-
clearing pivot table layouts, 40 year reports, 417-419
Code window (Visual Basic Editor), 326 Power Pivot
coding (object-oriented) calculated columns, adding in Power
data ranges, 327-328 Pivot grid, 281-282
End+Down arrow versus End+Up arrow, 328 categorizing columns with Power Pivot,
shortening code, 329 287

super-variables, 328-329 hiding columns in Power Pivot, 287

With and End With, 329 renaming columns with Power Pivot, 287

Collie, Rob, 143, 287, 425, 432 sorting one column by another with
Power Pivot, 282

447
columns

Power Query constants and calculations, 139


adding columns with, 275-276 converting
column-level actions, 198-200 live pivot tables to static values (case study),
removing columns with Power Query 54-55
Editor, 191 pivot tables
splitting columns, 204-206 to cube formulas, 232-238
rearranging, 83-84 to values, 338-341
removing columns with Power Query Editor, copying pivot tables to workbooks, 349-350
191 Count Distinct, 266-267, 357
renaming columns with Power Pivot, 287 Count of Revenue bug, 62
slicers, adding columns to, 100 Create PivotTable dialog box, basic pivot table
sorting one column by another with Power creation
Pivot, 282 choosing report location, 20
splitting columns with Power Query, 204-206 data selection, 20
subtotals (multiple), adding to one field, 72 PivotTable Fields list, 21-22
Values columns, filtering Label columns, 91-92 creating pivot tables
widths basic pivot table creation, 19
AutoFit, 59 adding fields to reports, 22-24
vertically arranged pivot tables, 59 adding fields to tables, 21-24
Columns area, 5, 22 adding layers to reports, 25
Comments tool (VBA), 326 choosing report location, 20
Compact layout, 51-53, 58, 75-76 classic pivot table layout, 26-27
comparing creating filters, 27
line-to-line comparisons, Value field calcu- data selection, 20
lations, 66 dragging/dropping fields in reports and
tables with pivot tables, 400-401 tables, 25-26
compatibility Ideas feature, 29-30
Check Compatibility tool, 7-9 laying out reports, 22-24, 39-40
pivot tables and Excel, 7-8 PivotTable Fields list, 21-22
slicers, 7 rearranging tables, 25-26
timelines, 7 Recommended PivotTables, 28-30
Timeline slicer, 35 slicers, 31-35
conceptual filters in VBA, 374-377 from Data Model, 283
conditional formatting of pivot tables Pivot Power Premium add-in, 45
customizing rules, 168-172 VBA and, 330-331
example of conditional formatting, 165-167 adding fields to data areas, 332-333
preprogrammed scenarios, 167-168 filling blank cells in data or row area, 336
formatting tables, 333-335

448
customizing

preventing errors from inserting/ changing field names, 49


deleting cells, 336-337 converting live pivot tables to static
totals, 337-338 values (case study), 54-55
cube formulas Count of Revenue bug, 62
CUBEMEMBER function, 234 default pivot tables, 44
CUBERANKEDMEMBER function, 236 formatting cells in Office 365, 72
CUBESET function, 235-238 grand totals, 50, 57-58
CUBEVALUE function, 233-236 gridlines, 45
GETPIVOTDATA function versus, 232 layouts, 50-53, 56-58, 75-76
pivot tables, converting to cube formulas, subtotals, 50
232-238 number format, thousands separators,
SORTBY function, 238 46-47
cube functions, 248-250 Pivot Power Premium add-in, 45
CUBEMEMBER function, 234 previewing changes with Live Preview
CUBERANKEDMEMBER function, 236 feature, 60
cubes (OLAP) replacing blank cells with zeros, 47-48
connecting to, 239-242 settings, xxiv
dimensions of, 243 styles, 45, 59-62
functions, 248-250 subtotals, 50, 70-72
hierarchies of, 243, 257 Value field calculations, 63-70
levels of, 243 sort lists, 390-391
measures of, 243, 250-253 Value field calculations, 63-65
members of, 243, 250, 254-257 % Difference From option (Value Field
offline cubes, 245-247 Settings dialog box, Show Values As
PivotTable Fields list, 244 tab), 68-69
structure of, 242-243 % Of option (Value Field Settings dialog
CUBESET function, 235-238 box, Show Values As tab), 66

CUBEVALUE function, 233-236 % Of Parent Column option (Value Field


Settings dialog box, Show Values As
custom lists, sorting, 84-86, 286
tab), 69
custom maps (3D Map), 290
% Of Parent Row option (Value Field
custom shapes (3D Map), 290
Settings dialog box, Show Values As
customers, sorting into high-to-low sequences
tab), 69
based on revenue, 79-82
% Of Parent Total option (Value Field
customizing
Settings dialog box, Show Values As
conditional formatting rules, 168-172
tab), 69
pivot tables, 44
blank cells, 47-48
blank rows, 50, 56-57

449
customizing

% Of Total option (Value Field Settings pivot caches, 383


dialog box, Show Values As tab), 66 pivot tables
Index option (Value Field Settings dialog adding model fields to, 383
box, Show Values As tab), 69-70 adding numeric fields to Values area,
line-to-line comparisons, 66 384
ranking options, 67 converting to cube formulas, 232-238
running total calculations, 67-68 creating, 283-386
visualizations with Power BI Desktop, 221-222 Power Query data, outputting data to Data
Model, 193
primary keys, 177

D relationships
activating, 180
Dalgleish, Debra, 45 creating, 178-180
data areas creating between tables, 382
blank cells, filling in data areas, 336 deactivating, 180
fields, adding to, 332-333 deleting, 180
data cards (tooltips), 3D Map, 296 editing, 180
data items, sorting in a unique sort order, managing, 179
389-390
tables
Data Model, 330
adding linked tables to Data Model, 279
32-bit Excel and, 287
adding to Data Model, 180, 381
adding
creating relationships, 382
linked tables to Data Model, 279
defining relationships between tables,
model fields to pivot tables, 383 279-280
numeric fields to Values area, 384 text, reporting in Values area, 272
tables to Data Model, 279, 381 Values area, reporting text in, 272
creating, 176-179 VLOOKUP functions, replacing with Data
cube formulas, converting pivot tables to, Model, 261-266
232-238 data ranges
DAX measures and median calculations, automatically expanding data ranges,
269-271 creating, 399
Distinct Count, 266-267 writing code for, 327-328
Filtered Items in Totals, 269 data sets
limitations of, 180, 286-287 combining in 3D Map, 297
loading to Data Model instead of Excel grid, exploding
277-278
to different tabs in pivot tables, 410-411
median calculations with DAX measures,
to different workbooks, 415-417
269-271
transposing with Power Query (case study),
202-204
450
documenting

data sources DAX measures, 139


blank cells in, 14 defined, 121
calculated fields, manually adding to data median calculations, 269-271
sources, 122-123 using DAX measures instead of calculated
cleaning up (case study), 15-19 fields (case study), 141-145
column headings, 11 Debugging tool (VBA), 326
disparate data sources default pivot tables
defined, 175 behaviors, changing for future pivot tables,
ETL processes, 188 392
external data, creating pivot tables, customizing, 44
181-187 deferring pivot table layout updates, 39-40
external data, defined, 175 Delete key versus spaces, 24
multiple ranges, defined, 175 deleting
Power Query and, 189-193, 202 calculations, 146-147
empty columns in, 14 cells, preventing errors, 336-337
empty rows in, 14 Data Model relationships, 180
gaps in, 14 pivot tables (underlying), pivot charts and, 162
good design techniques, 14 source data worksheets, 398
refreshing dimensions of OLAP cubes, 243
changes made to existing data sources, disabling macros, 324
36 disparate data sources
expanded data source ranges, 37 defined, 175
databases ETL processes, 188
OLAP databases, 239-240, 250-251 external data
transactional databases, 239 creating pivot tables, 181-187
date fields, grouping defined, 175
by week, 110-111 multiple ranges, defined, 175
including years when grouping by months, Power Query and, 189-193, 202
110 Distinct Count, 266-267, 338
manually grouping, 108-109 distributions (frequency), creating with pivot
Date Filters, 94-96, 101, 375 tables, 409-410
date groups, xxiv docking/undocking Fields list, 77
AutoGroup feature, 344 document themes, modifying styles with, 61-62
VBA and, 344-346 documenting
DAX formulas, 285 calculations, 148
DAX functions, xxiv formulas, 148

451
Doodads rule

Doodads rule, Sort by, 82-83 Excel grid, loading to Data Model instead,
dragging/dropping fields in reports, 25-26 277-278
drill-down methods, 286 Excel Help tool (VBA), 326
exploding data sets
to different tabs, 410-411

E to workbooks, 415-417
external data
editing defined, 175
calculations, 146, 147 pivot tables, creating, 181
Data Model relationships, 180 from Access (MS) data, 181-184
empty cells filling in row fields, 393 from SQL Server data, 184-187
Go To Special function (Excel), 395-396 extracting cells from pivot tables based on pivot
Repeat All Item Labels feature, 394-395 caches, 232
empty columns in data sources, 14 extracts, creating, 3
empty rows in data sources, 14
End+Down arrow versus End+Up arrow, coding,
328
End With and With, coding, 329
F
erasing pivot table layouts, 40 February 29 1900 and Power Pivot, 286-287
Escobar, Miguel, 287 Field list, Areas section drop-downs, 78-79
ETL (Extraction, Transformation, Loading) fields
processes, 188 adding to reports, 22-24
“evil GetPivotData problem”, 426-428 calculated fields, 286, 358-359
Excel creating, 123-128
32-bit Excel defined, 121
Data Model and, 287 inserting into pivot tables, 124-125
Power Pivot and, 287 manually adding to data sources,
Go To Special function, filling empty cells in 122-123
row fields, 395-396 rules specific to, 139-140
pivot tables, backward compatibility, 7, 8 summarizing next year’s forecast (case
versions of, 330 study), 129-133
Excel 2019 using DAX measures instead of cal-
Office 365 versus, xxix-xxx culated fields (case study), 141-145
recommended pivot tables, xxvii changing names, 49
ribbon, xxix-xxx collapsing/expanding in Compact layouts, 51
system requirements, xxxii column fields
Excel 2019 In Depth, 306 adding multiple subtotals to one field, 72
filtering, 88

452
filters

data areas, adding fields to, 332-333 filtering, 88


date fields suppressing subtotals in, 348
grouping by week, 110-111 turning subtotals on/off in, 70-71
grouping manually, 108-109 text fields, grouping for redistricting (case
including years when grouping by study), 106-108
months, 110 Value field, customizing calculations, 63-70
dragging/dropping in reports, 25-26 Fields list
expanding/collapsing in Compact layouts, 51 docking/undocking, 77
filter fields, 369-373. See also page fields rearranging, 77-78
(VBA) filling
Filters area, adding fields to, 96 blank cells
formatting, 14 in data area, 336
model fields, adding to pivot tables, 383 in row area, 336
multiple data fields, troubleshooting issues empty cells in row fields, 393
with, 355-356 Go To Special function (Excel), 395-396
naming fields, 49 Repeat All Item Labels feature, 394-395
numeric fields FILTER function, 238
adding to Values area, 384 filters, 32. See also slicers
grouping, 104-105 3D Map, 296
rank number fields, adding to pivot AutoFiltering pivot tables, 401-404
tables, 396-398 conceptual filters in VBA, 374-377
page fields (VBA), 369-373. See also filter date filters in VBA, 375
fields Filtered Items in Totals, 269
pivot fields filter fields, 369-373. See also page fields
manually filtering multiple items in, (VBA)
373-374 label filters in VBA, 374
restrictions, 413-415 pivot fields, manually filtering multiple items
PivotTable Fields list, 21-22 in, 373-374
adding fields to tables, 24 pivot tables
dragging/dropping fields in tables, AutoFiltering pivot tables, 401-404
25-26 check boxes, 88-89
primary keys, 177 column fields, 88
rank number fields, adding to pivot tables, Date Filters, 94-96
396-398
dates, filtering by, 101
row fields
Filters area, 96-97
adding multiple subtotals to one field,
labels, 90-96
72
overview of, 86-87
filling empty cells, 393-396

453
filters

replicating reports for each item in a fields, 14


filter, 97-98 individual values in pivot tables, 405-407
row fields, 88 numbers
search box, 89-90 multiple number formats in pivot tables,
slicers, 99-104, 378-380 404-405
Timeline slicers, 101-104 thousands separators, 46-47
Top 10 filter, 93-94 pivot charts, 156
Values columns, filtering Label columns, pivot tables, 333-335, 350
91-92 sections of pivot tables, 407-408
recordsets, filtering with ShowDetail (VBA), slicers, 100-101
367-373 formulas
search filter in VBA, 377, 378 arrow keys in formula creation, 286
Top 10 filter, 268 calculated fields, creating with formulas
value filters in VBA, 375 outside a pivot table, 123-124
Filters area, 6, 22 documenting, 148
adding fields to, 96 GetPivotData, preventing, 429
choosing List Formulas command, 148
multiple items from a filter, 97 frequency distributions, creating with pivot
one item from a filter, 96 tables, 409-410
creating filters, 27 functions (OLAP cube), 248-250
flat maps in 3D Map, 295, 296
fonts and themes, 62
forecasts, summarizing next year’s forecast G
(case study), 129-133
form controls Gainer, Dave, 425
ActiveX controls versus, 307 geocoding data in 3D Map, 290-291
defined, 306 GeoFlow. See 3D Map
macros, assigning to form controls, 308 GetPivotData, 425
scrollbars, adding to spreadsheets, 309-312 default status, determining reasons for its,
user interfaces, creating, 306-308 430-431

viewing, 307 pivot table annoyances, solving, 431

formatting creating shell reports, 435-436

cells in Office 365, 72 creating ugly pivot tables, 432-435

conditional formatting and pivot tables populating shell reports, 437-440

customizing rules, 168-172 updating shell reports, 441-442

example of conditional formatting,


165-167
preprogrammed scenarios, 167-168

454
Insights feature and Power BI Desktop

preventing
by turning off GetPivotData, 429-430
H
by typing the formula, 429 hard data, turning pivot tables into, 393
problems with, 426-428 headings
GETPIVOTDATA function column headings, 11
cube formulas versus, 232 section headings, storing data in, 12
extracting cells from pivot tables based on heat maps in 3D Map, 294
pivot caches, 232 help
Get & Transform tools, cleaning up data sources Excel Help tool (VBA), 326
(case studies), 15-19 support/feedback, xxxii
globes, using store maps instead of (case study), hiding
299-302 columns with Power Pivot, 287
Go To Special function (Excel), empty cells, filling legends in 3D Map, 296
in row fields, 395-396 panes in 3D Map, 296
grand totals hierarchies, 116-118
calculations, grand total references, 139 drill-down hierarchies, 219-220
controlling with VBA, 337-338 OLAP cubes, 243, 257
layouts, 50, 57-58 Power Pivot and, 287
gridlines, restoring to pivot tables, 45 high-to-low sequences, sorting customers in
grouping based on revenue, 79-82
auto date-grouping, 75 Hoter, Dany, 238
AutoGroup
determining AutoGroup criteria, 111
using, 112
year-over-year reports, 113-115
I
calculating groups, 361-362 Ideas feature, 29-30
date fields images in Power BI Desktop, 212
by week, 110-111 importing
including years when grouping by custom visualizations, Power BI Desktop,
months, 110 221-222
manually grouping, 108-109 data to Power BI Desktop, 208
date grouping, xxiv Index option (Value Field Settings dialog box,
numeric fields, 104-105 Show Values As tab), 69-70
pivot tables, 286 individual values, formatting in pivot tables,
repeating as columns, 13 405-407

text fields for redistricting (case study), Insert Slicers dialog box, 31-32
106-108 Insights command (Office 365), xxiv
Insights feature and Power BI Desktop, 224

455
interactive reports

interactive reports latitude (3D Map), 290


Power BI Desktop, creating reports with layers, adding to reports, 25
cross-filtering charts, 218 layouts, 22-24
drill-down hierarchies, 219-220 blank rows, 50, 56-57
mobile phones, designing reports for, classic pivot table layout, 26-27
223 Compact layout, 51-53, 58, 75-76
publishing to Power BI Desktop, 222 deferring layout updates, 39-40
visualizations, 213-217, 221-224 grand totals, 50, 57-58
showing revenue by product and time period Outline layout, 52-53
(case study), 157-161 subtotals, 50
interactive web pages, workbooks as, 226-229 Tabular layout, 12-14, 53, 75-76, 344
item labels, repeating, 52 vertically arranging pivot tables, 59
legends (3D Map), 296
life after pivot tables (case study), xxvii-xxix
J–K life before pivot tables (case study), xxiv-xxvi
line-to-line comparisons, Value field calculations,
Javelin, xxvi
66
Jelen, Bill, 306
linked tables, adding to Data Model, 279
links, sharing to workbooks, 229
List Formulas command, 148
L lists (custom), sorting, 84-86, 286
live pivot tables, converting to static values (case
Label columns, filtering with Values column infor-
study), 54-55
mation, 91-92
Live Preview feature, 60
Label Filters option, filtering with, 90-91
loading to Data Model instead of Excel grid,
labeling
277-278
column labels, splitting between two rows, 12
longitude (3D Map), 290
data points in 3D Map, 294
Lotus, xxvi
Date Filters, 94-96
Lotus Improv, xxvi
filtering, 90-91
label filters in VBA, 374
maps in 3D Map, 295
Repeat All Item Labels, 330, 394-395 M
repeating item labels, 52 M is for Data Monkey, 195, 287
row labels, turning on/off in Compact layout, M language
58
applied steps (Power Query), 194-195
large data files, processing with Power Query,
viewing, 276
273-275
Macro Recorder versus Power Query, 277

456
measures (DAX)

macros, 330 flat maps, 295-296


benefits of, 303 geocoding data, 290-291
creating heat maps, 294
Power Query, 313-321 hiding
VBA Macro Controller, 310-312 legends, 296
defined, 303 panes, 296
disabling, 324 labeling
enabling, 323-325 data points, 294
form controls, assigning macros to, 308 maps, 295
functionality, adding to recorded macros, latitude, 290
308-309 legends
macro recorder, 326-328 hiding, 296
pivot table reports and, 303 resizing, 296
recording, 304-305, 308-309 longitude, 290
scrollbars, adding to spreadsheets, 309-312 navigating maps, 292-293
security, 305-306 pie charts, 294
VBA Macro Controller, 310-312 preparing data for, 289
managing region maps, 294
calculations, OLAP pivot tables, 257-258 relationships (table), 290
Data Model relationships, 179 resizing legends, 296
queries in Power Query, 196-198 store maps, using instead of globes (case
manual sort sequences, 82, 83, 84 study), 299-302
manually table relationships, 290
adding calculated fields to data sources, timelines, 298
122-123 tours, creating, 298-299
grouping date fields, 108-109 vantage point, moving, 293
maps (3D), 289 video, creating, 299
aerial photography maps, 295 zooming in/out of maps, 293
animating data over time, 297-298 market activity analysis (case study), 35-36
annotation (text boxes), 294, 299 McDaid, Joe, 238
bubble charts, 294 MDX (Multidimensional Expressions), 250
column charts, 292, 296 calculated measures, 251-253
combining data sets, 297 calculated members, 254-257
custom maps, 290 MDX Solutions, 251
custom shapes, 290 measures (DAX), 139
data cards (tooltips), 296 defined, 121
filters, 296 median calculations, 269-271

457
measures (DAX)

OLAP cubes, 243, 250-253 numeric columns in blank cells, 24


Power Pivot, 384. See also calculations numeric fields
using DAX measures instead of calculated adding to Values area, 384
fields (case study), 141-145 grouping, 104-105
median calculations with DAX measures, 269-271
members of OLAP cubes, 243, 250, 254-257
Merge queries, 421
O
mobile phones, designing interactive reports for,
223 object-oriented coding
model fields, adding to pivot tables, 383 data ranges, 327-328
modifying styles with document themes, 61-62 End+Down arrow versus End+Up arrow, 328
months, grouping by, 110 shortening code, 329
mouse, manual sort sequences, 83-84 super-variables, 328-329
Movie PivotTable dialog box, 41 With and End With, 329
multiple data fields, troubleshooting issues with, Office 365
355-356 costs of, xxxi
multiple number formats in pivot tables, 404-405 Excel 2019 versus, xxix-xxx
multiple ranges, defined, 175 formatting cells, 72
Insights command, xxiv
new features of, xxx-xxxi

N ribbon, xxx
offline cubes, creating, 245-247
named ranges and calculations, 139 OLAP (Online Analytical Processing)
named sets, 330 cubes
naming connecting to, 239-242
fields, 49 dimensions of, 243
pivot tables, 33 functions, 248-250
natural language queries and Power BI Desktop, hierarchies of, 243, 257
213 levels of, 243
navigating maps in 3D Map, 292-293 measures of, 243, 250-253
next year’s forecast (case study), summarizing, members of, 243, 250, 254-257
129-133
offline cubes, creating, 245-247
number fields (rank), adding to pivot tables,
PivotTable Fields list, 244
396-398
structure of, 242-243
number formats
databases, 239-240, 250-251
changing in pivot tables, 347-348
pivot tables
multiple formats in pivot tables, 404-405
adding calculations to, 250
thousands separators, 46-47
limitations of, 244-245

458
pivot table reports

managing calculations, 257-258 interactive reports showing revenue by


MDX and, 250-251 product and time period (case study),
what-if analysis of OLAP data, 258-259 157-161
OneDrive workbooks, sharing links to, 229 pivot field buttons, 152-153, 160
operator precedence and calculations, 138 pivot tables and
Outline layout, 52-53 effects of changes in pivot tables on
pivot charts, 154
placement of data fields in pivot tables

P x-axis, 155
on pivot charts, 154-156

page breaks, subtotals as, 350-351 XY scatter charts, 164-165


page fields (VBA), 369-373. See also filter fields y-axis, 155
percentage change column for year-over-year pivot field buttons (pivot charts), 152-153, 160
reports, 417-419 pivot fields
pictures of pivot charts, distributing, 163 manually filtering multiple items in, 373-374
pie charts in 3D Map, 294 restrictions, 413-415
pivot caches, 7, 398 Pivot Power Premium add-in, 45
cells, extracting from pivot tables based on PivotTable Fields list, 21-22
pivot caches, 232 fields
Data Model tables and, 383 adding to tables, 24
defining, 383 dragging/dropping in tables, 25-26
refreshing, 6 OLAP cubes, 244
changes made to existing data sources, pivot table reports, 1
36 column headings, 11
expanded data source ranges, 37 layouts, 22-24
sharing, 37-39 classic layout, 26-27
pivot charts deferring layout updates, 39-40
alternatives to, 161 starting over, 40
deleting underlying pivot tables, 162 location of, choosing, 20
distributing pictures of pivot charts, 163 macros, 303
pivot table-linked cells as pivot chart pivot caches, 6-7
source data, 163-165 refreshing
turning pivot tables into hard values, 162 changes made to existing data sources,
creating, 150-153 36
defined, 149 expanded data source ranges, 37
formatting limitations, 156 size of, reducing, 398
snapshots, 6

459
pivot tables

pivot tables, 1 cells


anatomy of blank cells, deleting, 346-347
Columns area, 5 extracting from pivot tables based on
Filters area, 6 pivot caches, 232
Rows area, 5 Columns area, 5, 22
Values area, 4 comparing tables with, 400-401
annoyances, solving with GetPivotData, conditional formatting
431-432 customizing rules, 168-172
creating shell reports, 435,-436 example of, 165-167
creating ugly pivot tables, 432-435 preprogrammed scenarios, 167-168
populating shell reports, 437-440 converting live tables to static values (case
updating shell reports, 441-442 study), 54-55
basic creation, 19 copying as values to workbooks, 349-350
adding fields to reports, 22-24 creating. See also basic pivot table creation
adding layers to reports, 25 from Data Model, 283
choosing report location, 20 Pivot Power Premium add-in, 45
classic pivot table layout, 26-27 VBA and, 330-338
creating filters, 27 cube formulas, converting pivot tables to,
data selection, 20 232-238
dragging/dropping fields in reports, custom lists, sorting, 286
25-26 customizing, 44
Ideas feature, 29-30 blank cells, 47-48
laying out reports, 22-24, 39-40 blank rows, 50, 56-57
PivotTable Fields list, 21-26 changing field names, 49
rearranging tables, 25-26 converting live pivot tables to static
Recommended PivotTables, 28-30 values (case study), 54-55
slicers, 31-35 Count of Revenue bug, 62
blank cells, deleting, 346-347 default pivot tables, 44
calculated data fields, 358-359 formatting cells in Office 365, 72
calculated items, 359-361 grand totals, 50, 57-58
calculating groups, 361-362 gridlines, 45
calculating with, 355 layouts, 50-53, 56-58, 75-76
Show Values As tab (Value Field Settings subtotals, 50
dialog box), 362-363 number format, thousands separators,
VBA calculation options per Excel 46-47
version, 364 Pivot Power Premium add-in, 45
calculation functions, 356-358

460
pivot tables

previewing changes with Live Preview GetPivotData, solving annoyances with,


feature, 60 431-432
replacing blank cells with zeros, 47-48 creating shell reports, 435-436
settings, xxiv creating ugly pivot tables, 432-435
styles, 45, 59-62 populating shell reports, 437-440
subtotals, 50, 70-72 updating shell reports, 441-442
Value field calculations, 63-70 grouping, 286
Data Model hard data, turning pivot tables into, 393
adding model fields to, 383 Ideas feature, 29-30
adding numeric fields to Values area, life after (case study), xxvii-xxix
384 life before (case study), xxiv-xxvi
creating pivot tables, 283, 383-386 live tables, converting to static values (case
data sets, exploding study), 54-55
to different tabs, 410-411 limitations of, 7
to different workbooks, 415-417 Move PivotTable dialog box, 41
date groups and VBA, 344-346 multiple data fields, troubleshooting issues
default behaviors, changing for future pivot with, 355-356
tables, 392 naming, 33
default settings, xxiv new features, xxiii-xxiv
development of, xxvi number fields (rank), adding to pivot tables,
distributions (frequency), creating, 409-410 396-398
Excel backward compatibility, 7, 8 number format
extracts, creating, 3 changing, 347-348
filters multiple number formats in, 404-405
AutoFiltering pivot tables, 401-404 OLAP pivot tables
creating, 27 adding calculations to, 250
Filters area, 6, 22, 27 limitations of, 244-245
formatting, 333-335 managing calculations, 257-258
individual values in pivot tables, MDX and, 250-251
405-407 what-if analysis of OLAP data, 258-259
multiple number formats in pivot tables, page breaks, subtotals as, 350-351
404-405 product calculations, 286
sections of pivot tables, 407-408 rank number fields, adding to pivot tables,
VBA and, 350 396-398
frequency distributions, creating, 409-410 rearranging, 25-26
Recommended PivotTables, xxvii, 28-30
refreshing, 431

461
pivot tables

all pivot tables in a workbook at the creating reports for each region/model,
same time, 388 369-373
automatically refreshing, 388 creating revenue by category reports,
relocating, 41 341-344
restrictions, 412-413 date filters, 375
Rows area, 5, 22 date groups, 344-346
slicers deleting blank cells, 346-347
connecting to multiple pivot tables, filtering recordsets with ShowDetail,
32-33 367-373
standard slicers, 31-33 formatting pivot tables, 350
Timeline slicer, 34-35 label filters, 374
sort order, controlling with AutoSort, 347 manually filtering multiple items in pivot
sorting fields, 373-374
custom lists, 390-391 search filter, 377-378
unique sort order, 389-390 slicers, filtering pivot tables, 378-380
static values (case study), converting live subtotals as page breaks, 350-351
tables to, 54-55 summary reports, producing, 352-354
subtotals suppressing subtotals for multiple row
as page breaks, 350-351 fields, 348
suppressing for multiple row fields, 348 Tabular layouts, 344
Tabular layouts and VBA, 344 value filters, 375
ugly pivot tables, creating, 432-435 versions of, 330
updates, xxxii workbooks, copying pivot tables to, 349-350
usage examples, 2, 3 Power BI Custom Visuals, 173-174
Values area, 4, 22 Power BI Desktop, xxiv, 207
VBA cross-filtering charts, 218
AutoShow and executive overviews, drill-down hierarchies, 219-220
365-367 Excel, preparing data in, 208
calculating with pivot tables, 355-364 images in, 212
changing default number format, importing data to, 208
347-348 Insights feature, 224
conceptual filters, 374-377 interactive reports, creating
controlling sort order with AutoSort, 347 creating visualizations, 213-217
converting to values, 338-341 cross-filtering charts, 218
copying as values to workbooks, designing reports for mobile phones,
349-350 223
creating pivot tables, 330-338 drill-down hierarchies, 219-220

462
Power Query

importing custom visualizations, creating relationships between tables,


221-222 382
publishing to Power BI Desktop, 222 defining pivot caches, 383
publishing to workspaces, 223-224 February 29 1900, 286-287
natural language queries, 213 hierarchies, 116-118, 287
navigating, 209-210 limitations of, 286-287
preparing data in, 210-212 measures, 384. See also calculations
publishing to, 222 pivot tables, creating from Data Model, 283
Q&A feature, 225-226 relationships, 284
querying data, 225-226 time intelligence, 285
relationships, 210-213 using DAX measures instead of calculated
setting up, 207 fields (case study), 143
signing in, 207 Power Pivot and Power BI, 287
synonyms, defining, 213 Power Pivot Data Model, 330
visualizations, 209 Power Pivot for the Data Analyst, 282
creating, 213-217 Power Query
importing custom visualizations, Advanced Query Editor, 195
221-222 applied steps, 194-195, 276
workspaces, publishing to, 223-224 big data files, processing, 273-275
Power Map. See 3D Map cleaning up data sources (case studies), 15-19
Power Pivot, xxiv, 261 columns
32-bit Excel and, 287 adding, 275-276
benefits of, 287 Column From Examples feature, 275
columns column-level actions, 198-200
calculated columns, adding in Power removing, 191
Pivot grid, 281-282 splitting, 204-206
categorizing, 287 connection types, 202
hiding, 287 ETL processes, 188
renaming, 287 installing, 188
sorting one column by another, 282 M language
Data Model applied steps, 194-195
adding model fields to pivot tables, 383 viewing, 276
adding numeric fields to Values area, macros, creating, 313-321
384 managing queries, 196-198
adding tables to, 381 outputting data to Data Model, 193
creating pivot tables, 383-386 Power Query Editor, cleaning up data sources
(case studies), 16

463
Power Query

previewing data, 190 starting queries with Power Query, 188-190


queries web queries (Power Query)
managing, 196-198 Advanced Query Editor, 195
starting, 188-190 applied steps, 194-195
refreshing data, 196 column-level actions, 198-200
removing columns, 191 connection types, 202
splitting ETL processes, 188
columns, 204-206 installing, 188
rows, 204-206 managing queries, 196-198
table actions, 200-201 outputting data to Data Model, 193
transforming data, 190-192 previewing data, 190
transposing data sets (case study), 202-204 refreshing data, 196
two-way VLOOKUP, 419-424 removing columns, 191
VBA Macro Recorder versus, 277 splitting columns/rows, 204-206
Power View, xxiv starting queries, 188-190
previewing changes with Live Preview feature, 60 table actions, 200-201
primary keys, 177 transforming data, 190-192
product calculations, 286 transposing data sets (case study),
Project Explorer (Visual Basic Editor), 325 202-204
properties (VBA coding), 327
Properties window (Visual Basic Editor), 326
publishing R
interactive reports to workspaces, 223-224
ranges
to Power BI Desktop, 222
multiple ranges, defined, 175
Puls, Ken, 195, 287
named ranges and calculations, 139
rank number fields, adding to pivot tables,
396-398
Q ranking, Value field calculations, 67
Q&A feature and Power BI Desktop, 225-226 rearranging
queries columns, 83-84
managing queries with Power Query, 196-198 Fields list, 77-78
Merge queries, 421 pivot tables, 25, 26
natural language queries, 213 Recommended PivotTables, xxvii, 28-30
Power BI Desktop redistricting, grouping text fields for (case study),
natural language queries, 213 106-108
querying data with Q&A feature,
225-226

464
reports

references and calculations relocating pivot tables, 41


cell references, 139 removing columns with Power Query Editor, 191
totals, 139 renaming columns with Power Pivot, 287
refreshing re-ordering items, 286
data in Power Query, 196 Repeat All Item Labels, 330, 394-395
data sources repeating
changes made to existing data sources, groups as columns, 13
36 item labels, 52
expanded data source ranges, 37 replicating reports for each item in a filter, 97-98
pivot caches, 6 report layouts, 50
changes made to existing data sources, blank rows, 50, 56, 57
36 Compact layout, 51, 53, 75, 76
expanded data source ranges, 37 turning row labels on/off, 58
pivot table reports grand totals, 50, 57, 58
changes made to existing data sources, Outline layout, 52, 53
36 subtotals, 50
expanded data source ranges, 37 Tabular layout, 53, 75, 76
pivot tables, 431 reports
all pivot tables in a workbook at the filters, replicating reports for each item in a,
same time, 388 97-98
automatically refreshing, 388 interactive reports, creating with Power BI
slow refreshes, 286 Desktop
region maps in 3D Map, 294 creating visualizations, 213, 214, 215, 217
relationships cross-filtering charts, 218
3D Map table relationships, 290 designing reports for mobile phones,
Data Model 223
activating relationships, 180 drill-down hierarchies, 219, 220
creating relationships, 178-180 importing custom visualizations, 221,
deactivating relationships, 180 222
deleting relationships, 180 publishing to Power BI Desktop, 222
editing relationships, 180 publishing to workspaces, 223, 224
managing relationships, 179 layouts
tables, 279-280, 382 blank rows, 50, 56-57
Power BI Desktop, 210-213 Compact layout, 51-53, 58, 75-76
Power Pivot and, 284 grand totals, 50, 57-58
tables, defining relationships between tables Outline layout, 52-53
with Data Model, 279-280 subtotals, 50
Tabular layout, 53, 75-76

465
reports

macros, 303 blank cells, filling in row area, 336


replicating reports for each item in a filter, blank rows (layouts), 50, 56-57
97-98 column labels, splitting between two rows, 12
revenue by category reports, creating, empty cells, filling, 393
341-344 Go To Special function, 395-396
shell reports Repeat All Item Labels feature, 394-395
creating, 435-436 empty rows in data sources, 14
populating, 437-440 filtering fields, 88
updating, 441-442 labels, turning on/off in Compact layout, 58
size of, reducing, 398 multiple row fields, suppressing subtotals in,
summary reports, producing, 352-354 348
Top 5 Markets reports, 365-367 splitting with Power Query, 204-206
top-five reports, creating with Top 10 filter, subtotals
93-94 adding multiple subtotals to one field,
VBA, creating reports for each region/model, 72
369-373 suppressing for multiple row fields, 348
year-over-year reports turning on/off in row fields, 70,-71
creating, 113-115 Rows area, 5, 22
percentage change column and, 417-419 running total calculations, Value field calculations,
requirements (system), xxxii 67-68
resizing legends (3D Map), 296
restrictions
pivot fields, 413-415
S
pivot tables, 412-413
revenue Salas, Pito, xxvi
interactive reports showing revenue by scatter charts, 164-165
product and time period (case study), scrollbars, adding to spreadsheets, 309-312
creating, 157-161 search box, filtering with, 89-90
revenue by category reports, creating, search filter in VBA, 377-378
341-344 section headings, storing data in, 12
sorting customers into high-to-low sequences security
based on revenue, 79-82 macros, 305-306
ribbon trusted locations, 306
Excel 2019, xxix-xxx shapes (custom) in 3D Map, 290
Office 365, xxx sharing
rows links to workbooks, 229
% Of Parent Row option (Value Field Settings pivot caches, 37-39
dialog box, Show Values As tab), 69

466
store maps

shell reports snapshots


creating, 435-436 pivot caches, refreshing, 6
populating, 437-440 pivot table reports, 6
updating, 441-442 solve order of calculated items, changing, 147
ShowDetail (VBA), filtering recordsets, 367-369 Sort by Doodads rule, 82-83
ShowPages (VBA), 370 SORTBY function, 238
Show Values As tab (Value Field Settings dialog sorting
box), 65 custom lists, 286
% Difference From option, 68-69 data items, unique sort order, 389-390
% Of option, 66 one column by another with Power Pivot, 282
% Of Parent Column option, 69 pivot tables
% Of Parent Row option, 69 custom lists, 84-86, 390-391
% Of Parent Total option, 69 manual sort sequences, 82-84
% Of Total option, 66 Sort by Doodads rule, 82-83
Index option, 69-70 sorting customers into high-to-low se-
performing calculations with, 362-363 quences based on revenue, 79-82
ranking options, 67 unique sort order, 389-390
running total calculations, 67-68 sort order, controlling with AutoSort, 347
size of pivot table reports, reducing, 398 source data worksheets, deleting, 398
slicers, 330. See also filters spaces
columns, adding to slicers, 100 as text, 24
compatibility, 7 Delete key versus, 24
filtering with, 99-101, 378-380 splitting
formatting, 100-101 columns
Insert Slicers dialog box, 31-32 labels between two rows, 12
multiple pivot tables columns with Power Query, 204-206
connecting to, 32-33 rows with Power Query, 204-206
driving from, 102-104 Spofford, George, 251
slicing the measures, 243 spreadsheets, adding scrollbars to, 309-312
standard slicers, creating, 31-33 SQL Server, creating pivot tables from SQL Server
Timeline slicers, 101 data, 184-187
compatibility, 35 standard slicers, creating, 31-33
creating, 34-35 starting over, pivot table layouts, 40
driving multiple tables from, 102-104 static values, converting live pivot tables to (case
interactive reports showing revenue study), 54-55
by product and time period (case store maps, using instead of a globe (case study),
study), creating, 158-159 299-302

467
store maps

storing data in section headings, 12 pivot tables, comparing with, 400-401


styles Power Query, table actions, 200-201
creating, 60 relationships
customizing, 60 3D Map relationships, 290
modifying with document themes, 61-62 defining with Data Model, 279-280
pivot table styles, 59 styles, applying, 45
applying, 45 Tabular layout, 12-14, 53, 75-76, 344
creating styles, 60 text
customizing styles, 60 spaces as, 24
modifying with document themes, Values area, reporting text in, 272
61-62 text boxes (annotation) in 3D Map, 294, 299
subtotals, 50 text fields, grouping for redistricting (case study),
calculations, subtotal references, 139 106-108
controlling with VBA, 337-338 themes
multiple subtotals, adding to one field, 72 document themes, modifying styles with,
page breaks, 350-0351 61-62
row fields, turning subtotals on/off in, 70-71 fonts, 62
Sum, Count of Revenue bug, 62 thousands separators (number format), 46-47
SUMIFS function, xxv-xxviii time intelligence (Power Pivot), 285
summarizing next year’s forecast (case study), Timeline slicers, 101
129-133 compatibility, 35
summary reports, producing, 352-354 creating, 34-35
SUMPRODUCT function. See SUMIFS function driving multiple tables from, 102-104
Supercharge Excel, 287 interactive reports showing revenue by
super-variables, coding, 328-329 product and time period (case study),
support/feedback, xxxii creating, 158-159
synonyms, defining in Power BI Desktop, 213 timelines
system requirements, xxxii 3D Map tours, 298
compatibility, 7
tooltips (data cards) in 3D Maps, 296

T Top 5 Markets reports, 93-94, 365-367


Top 10 filter, 93-94, 268
tables totals
adding to Data Model, 180 calculations, referencing in, 139
Data Model Filtered Items in Totals, 269
adding tables to, 180 pivot tables, controlling totals, 337-338
defining relationships, 279-280 tours (3D Map), creating, 298-299
linked tables in, 279

468
VBA (Visual Basic for Applications)

transactional databases, 239 % Of Parent Column option (Value Field


transposing data sets with Power Query (case Settings dialog box, Show Values As tab),
study), 202-204 69
Trust Center, enabling macros, 323-324 % Of Parent Row option (Value Field Settings
trusted locations, 306 dialog box, Show Values As tab), 69
turning on/off % Of Parent Total option (Value Field Settings
GetPivotData, 429-430 dialog box, Show Values As tab), 69
row labels in Compact layout, 58 % Of Total option (Value Field Settings dialog
subtotals in row fields, 70-71 box, Show Values As tab), 66

two-way VLOOKUP, 419-424 Index option (Value Field Settings dialog box,
Show Values As tab), 69-70
line-to-line comparisons, 66

U performing calculations with, 362-363


ranking options, 67
ugly pivot tables, creating, 432-435 running total calculations, 67-68
undocking/docking Fields list, 77 values
unique sort orders, 389-390 filters in VBA, 375
updates, xxxii pivot tables, converting to, 54-55, 338-341
pivot caches Values area, 4, 22
changes made to existing data sources, fields, changing names, 49
36 text, reporting in, 272
expanded data source ranges, 37 Values columns, filtering Label columns, 91-92
pivot table updates, deferring, 39-40 vantage point (3D Map), moving, 293
shell reports, 441-442 VBA (Visual Basic for Applications)
slow refreshes, 286 AutoComplete tool, 326
user interfaces AutoShow, executive overviews of pivot
creating with form controls, 306-308 tables, 365-367
defined, 306 coding, properties, 327
Comments tool, 326
conceptual filters, 374-377

V date filters, 375


Debugging tool, 326
Value field, customizing calculations, 63-65 enabling, 323-324
% Difference From option (Value Field Excel Help tool, 326
Settings dialog box, Show Values As tab), label filters, 374
68-69
% Of option (Value Field Settings dialog box,
Show Values As tab), 66

469
VBA (Visual Basic for Applications)

Macro Controller date filters, 375


macros, creating, 310-312 filtering recordsets with ShowDetail,
scrollbars, adding to spreadsheets, 367-373
310-312 label filters, 374
Macro Recorder versus Power Query, 277 manually filtering multiple items in pivot
object-oriented coding fields, 373-374
data ranges, 327-328 search filter, 377-378
End+Down arrow versus End+Up arrow, slicers, filtering pivot tables, 378-380
328 value filters, 375
shortening code, 329 pivot tables, calculating with
super-variables, 328-329 calculated data fields, 358-359
With and End With, 329 calculated items, 359-361
page fields, 369-373. See also filter fields calculating groups, 361-362
pivot fields, manually filtering multiple items calculation functions, 356-358
in, 373-374 Show Values As tab (Value Field Settings
pivot tables dialog box), 362-363
changing default number format, troubleshooting issues with multiple
347-348 data fields, 355-356
converting to values, 338-341 VBA calculation options per Excel
copying as values to workbooks, version, 364
349-350 pivot tables, creating, 330-331
date groups, 344-346 adding fields to data areas, 332-333
deleting blank cells, 346-347 filling blank cells in data or row area, 336
formatting, 350 formatting tables, 333-335
producing summary reports, 352-354 preventing errors from inserting/de-
sort order, controlling with AutoSort, leting cells, 336-337
347 totals, 337-338
revenue by category reports, 341-344 reports, creating for each region/model,
subtotals as page breaks, 350-351 369-373
subtotals, suppressing for multiple row search filter, 377-378
fields, 348 ShowDetail, filtering recordsets, 367-369
Tabular layouts, 344 ShowPages, 370
pivot tables, advanced techniques slicers, filtering pivot tables, 378-380
AutoShow and executive overviews, summary reports, producing, 352-354
365-367 value filters, 375
conceptual filters, 374-377
creating reports for each region/model,
369-373

470
workbooks

Visual Basic Editor


Code window, 326
W
Project Explorer, 325 web pages (interactive),workbooks as, 226-229
Properties window, 326 web queries (Power Query)
vertically arranging pivot tables, 59 Advanced Query Editor, 195
video, creating with 3D Map, 299 applied steps, 194-195
Visual Basic Editor column-level actions, 198-200
Code window, 326 connection types, 202
Project Explorer, 325 ETL processes, 188
Properties window, 326 installing, 188
visualizations managing queries, 196-198
customizing with Power BI Desktop, 221-222 outputting data to Data Model, 193
pivot charts previewing data, 190
alternatives to, 161-165 refreshing data, 196
creating, 150-153 removing columns, 191
creating interactive reports showing splitting columns/rows, 204-206
revenue by product and time period starting queries, 188-190
(case study), 157-161 table actions, 200-201
defined, 149 transforming data, 190-192
effects of changes in pivot tables on transposing data sets (case study), 202-204
pivot charts, 154 weeks, grouping date fields by, 110-111
formatting limitations, 156 what-if analysis, OLAP pivot table data, 258-259
pivot field buttons, 152-153, 160 widths (columns)
placement of data fields in pivot tables AutoFit, 59
on pivot charts, 154-156 vertically arranged pivot tables, 59
x-axis, 155 With and End With, coding, 329
XY scatter charts, 164-165 workbooks
y-axis, 155 data sets, exploding to different workbooks,
Power BI Custom Visuals, 173-174 415-417
Power BI Desktop, 209 interactive web pages, workbooks as, 226-229
creating visualizations, 213-217 macros, enabling, 325
importing custom visualizations, pivot tables
221-222 copying pivot tables to, 349-350
VLOOKUP, 206 refreshing all pivot tables at the same
Data Model, replacing with, 261-266 time, 388
two-way VLOOKUP, 419-424 sharing links to, 229

471
worksheets

worksheets
functions and calculations, 139
Y
source data worksheets, deleting, 398 y-axis (pivot charts), 155
workspaces, publishing interactive reports to, year-over-year reports
223-224 creating, 113-115
percentage change column and, 417-419
years

X including when grouping by months, 110


summarizing next year’s forecast (case study),
x-axis (pivot charts), 155 129-133
.xls file format, enabling macros, 325
.xlsb file format, enabling macros, 325
.xlsm file format, enabling macros, 325
XY scatter charts, 164-165
Z
zeros, replacing blank cells with, 47-48
zooming in/out of maps in 3D Map, 293

472

You might also like