Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Part I.
Data Cleaning and Transformation with Power Query
1. Tables: The Portal to Modern Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Creating and Referring to Table Headers
Viewing the Table Footers
Naming Excel Tables
Formatting Excel Tables
Updating Table Ranges
Organizing Data for Analytics
Conclusion
Exercises
3
6
8
9
9
10
11
11
2. First Steps in Excel Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
What Is Power Query?
Power Query as Excel Myth Buster
“Excel Is Not Reproducible”
“Excel Does Not Have a True null”
“Excel Can’t Process More Than 1,048,576 Rows”
Power Query as Excel’s ETL Tool
Extract
Transform
Load
A Tour of the Power Query Editor
The Ribbon Menu
Queries
13
13
13
14
15
15
15
17
18
18
19
21
iii
The Imported Data
Exiting the Power Query Editor
Returning to the Power Query Editor
Data Profiling in Power Query
What Is Data Profiling?
Exploring the Data Preview Options
Overriding the Thousand-Row Limit
Closing Out of Data Profiling
Conclusion
Exercises
22
24
26
26
27
27
31
31
32
32
3. Transforming Rows in Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Removing the Missing Values
Refreshing the Query
Splitting Data into Rows
Filling in Headers and Cell Values
Replacing Column Headers
Filling Down Blank Rows
Conclusion
Exercises
34
37
39
42
42
43
44
44
4. Transforming Columns in Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Changing Column Case
Delimiting by Column
Changing Data Types
Deleting Columns
Working with Dates
Creating Custom Columns
Loading & Inspecting the Data
Calculated Columns Versus Measures
Reshaping Data
Conclusion
Exercises
45
47
47
48
48
49
51
52
53
54
55
5. Merging and Appending Data in Power Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Appending Multiple Sources
Connecting to External Excel Workbooks
Appending the Queries
Understanding Relational Joins
Left Outer Join: Think VLOOKUP()
Inner Join: Only the Matches
Managing Your Queries
iv
|
Table of Contents
57
58
61
62
64
68
70
Grouping Your Queries
Viewing Query Dependencies
Conclusion
Exercises
70
71
72
73
Part II. Data Modeling and Analysis with Power Pivot
6. First Steps in Power Pivot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
What Is Power Pivot?
Why Power Pivot?
Power Pivot and the Data Model
Loading the Power Pivot Add-in
A Brief Tour of the Power Pivot Add-In
Data Model
Calculations
Tables
Relationships
Settings
Conclusion
Exercises
77
77
80
81
83
83
83
84
84
84
84
85
7. Creating Relational Models in Power Pivot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Connecting Data to Power Pivot
Creating Relationships
Identifying Fact and Dimension Tables
Arranging the Diagram View
Editing the Relationships
Loading the Results to Excel
Understanding Cardinality
One-to-One Cardinality
One-to-Many Relationships
Many-to-Many Relationships
Why Does Cardinality Matter?
Understanding Filter Direction
Filtering orders with users
Filtering users with orders
Filter Direction and Cardinality
From Design to Practice in Power Pivot
Creating Columns in Power Pivot
Calculating in Power Query Versus Power Pivot
Example: Calculating Profit Margin
87
88
92
93
94
95
99
100
101
101
102
103
104
105
106
106
106
106
107
Table of Contents
|
v
Recoding Column Values with SWITCH()
Creating and Managing Hierarchies
Creating a Hierarchy in Power Pivot
Using Hierarchies in the PivotTable
Loading the Data Model to Power BI
Power BI as the Third Piece of “Modern Excel”
Importing the Data Model to Power BI
Viewing the Data in Power BI
Conclusion
Exercises
109
111
111
112
113
113
114
116
118
118
8. Creating Measures and KPIs in Power Pivot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Creating DAX Measures
Creating Implicit Measures
Creating Explicit Measures
Creating KPIs
Adjusting Icon Styles
Adding the KPI to the PivotTable
Conclusion
Exercises
119
119
122
128
130
131
132
132
9. Intermediate DAX for Power Pivot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
CALCULATE() and the Importance of Filter Context
CALCULATE() with One Criterion
CALCULATE() with Multiple Criteria
AND Conditions
OR Conditions
CALCULATE() with ALL()
Time Intelligence Functions
Adding a Calendar Table
Creating Basic Time Intelligence Measures
Conclusion
Exercises
Part III.
134
135
136
136
137
138
140
140
143
149
149
The Excel Data Analytics Toolkit
10. Introducing Dynamic Array Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Dynamic Array Functions Explained
What Is an Array in Excel?
Array References
Array Formulas
vi
|
Table of Contents
153
154
154
156
An Overview of Dynamic Array Functions
Finding Distinct and Unique Values with UNIQUE()
Finding Unique Versus Distinct Values
Using the Spill Operator
Filtering Records with FILTER()
Adding a Header Column
Filtering by Multiple Criteria
Sorting Records with SORTBY()
Sorting by Multiple Criteria
Sorting by Another Column Without Printing It
Creating Modern Lookups with XLOOKUP()
XLOOKUP() Versus VLOOKUP()
A Basic XLOOKUP()
XLOOKUP() and Error Handling
XLOOKUP() and Looking Up to the Left
Other Dynamic Array Functions
Dynamic Arrays and Modern Excel
Conclusion
Exercises
158
158
159
160
160
162
162
163
164
164
165
165
166
167
168
168
169
169
170
11. Augmented Analytics and the Future of Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
The Growing Complexity of Data and Analytics
Excel and the Legacy of Self-Service BI
Excel for Augmented Analytics
Using Analyze Data for AI Powered Insights
Building Statistical Models with XLMiner
Reading Data from an Image
Sentiment Analysis with Azure Machine Learning
Conclusion
Exercises
171
172
173
173
179
181
184
188
188
12. Python with Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Reader Prerequisites
The Role of Python in Modern Excel
A Growing Stack Requires Glue
Network Effects Mean Faster Development Time
Bring Modern Development to Excel
Using Python and Excel Together with pandas and openpyxl
Other Python Packages for Excel
Demonstration of Excel Automation with pandas and openpyxl
Cleaning Up the Data in pandas
Summarizing Findings with openpyxl
Table of Contents
190
190
190
191
192
193
194
195
196
200
|
vii
Adding a Styled Data Source
Conclusion
Exercises
204
206
207
13. Conclusion and Next Steps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Exploring Excel’s Other Features
LET() and LAMBDA()
Power Automate, Office Scripts, and Excel Online
Continued Exploration of Power Query and Power Pivot
Power Query and M
Power Pivot and DAX
Power BI for Dashboards and Reports
Azure and Cloud Computing
Python Programming
Large Language Models and Prompt Engineering
Parting Words
209
210
210
211
211
212
213
213
214
214
215
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
viii
|
Table of Contents