Data Mashup with Microsoft Excel Using Power Query and M: Finding, Transforming, and Loading Data from External Sources Adam Aspin pdf download
Data Mashup with Microsoft Excel Using Power Query and M: Finding, Transforming, and Loading Data from External Sources Adam Aspin pdf download
https://textbookfull.com/product/data-mashup-with-microsoft-
excel-using-power-query-and-m-finding-transforming-and-loading-
data-from-external-sources-adam-aspin/
https://textbookfull.com/product/data-visualization-in-
excel-2016-adam-aspin/
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
https://textbookfull.com/product/analyzing-data-with-microsoft-
power-bi-and-power-pivot-for-excel-1st-edition-alberto-ferrari-
marco-russo/
https://textbookfull.com/product/pro-power-bi-desktop-self-
service-analytics-and-data-visualization-for-the-power-user-3rd-
edition-adam-aspin/
Pro Power BI Desktop Self Service Analytics and Data
Visualization for the Power User Third Edition Adam
Aspin
https://textbookfull.com/product/pro-power-bi-desktop-self-
service-analytics-and-data-visualization-for-the-power-user-
third-edition-adam-aspin/
https://textbookfull.com/product/learning-apache-drill-query-and-
analyze-distributed-data-sources-with-sql-1st-edition-charles-
givre/
https://textbookfull.com/product/data-analysis-with-microsoft-
power-bi-brian-larson/
https://textbookfull.com/product/targeting-using-augmented-data-
in-database-marketing-decision-factors-for-evaluating-external-
sources-1st-edition-bettina-huttenrauch/
https://textbookfull.com/product/microsoft-excel-data-analysis-
and-business-modeling-5th-edition-wayne-winston/
Data Mashup
with Microsof t
Excel Using Power
Query and M
Finding, Transforming, and Loading Data
from External Sources
—
Adam Aspin
Data Mashup with
Microsoft Excel Using
Power Query and M
Finding, Transforming, and
Loading Data from
External Sources
Adam Aspin
Data Mashup with Microsoft Excel Using Power Query and M: Finding,
Transforming, and Loading Data from External Sources
Adam Aspin
Stafford, UK
Introduction������������������������������������������������������������������������������������������������������������xix
Chapter 1: Using Power Query to Discover and Load Data into Excel���������������������� 1
Power Query��������������������������������������������������������������������������������������������������������������������������������� 2
The Data Load Process����������������������������������������������������������������������������������������������������������������� 4
Why Use Power Query?����������������������������������������������������������������������������������������������������������������� 7
The Queries & Connections Pane�������������������������������������������������������������������������������������������������� 8
Displaying the Queries & Connections Pane���������������������������������������������������������������������������� 9
The Peek Window�������������������������������������������������������������������������������������������������������������������� 9
Peek Window Options������������������������������������������������������������������������������������������������������������ 10
View in Worksheet����������������������������������������������������������������������������������������������������������������� 11
Deleting a Query������������������������������������������������������������������������������������������������������������������������� 12
Understanding Data Load������������������������������������������������������������������������������������������������������������ 12
The Navigator Dialog������������������������������������������������������������������������������������������������������������� 13
Select Multiple Source Tables����������������������������������������������������������������������������������������������� 15
Searching for Datasets���������������������������������������������������������������������������������������������������������� 15
Navigator Display Options����������������������������������������������������������������������������������������������������� 17
Refresh���������������������������������������������������������������������������������������������������������������������������������� 17
The Navigator Data Preview�������������������������������������������������������������������������������������������������� 18
Modifying Data���������������������������������������������������������������������������������������������������������������������� 19
The Power Query Editor�������������������������������������������������������������������������������������������������������������� 20
Data Sources������������������������������������������������������������������������������������������������������������������������������� 20
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 379
xii
About the Author
Adam Aspin is an independent business intelligence consultant based in the United
Kingdom. He has worked with SQL Server for over 25 years. During this time, he has
developed several dozen reporting and analytical systems based on the Microsoft
Analytics Stack.
Business intelligence has been Adam’s principal focus for the last 20 years. He has
applied his skills for a variety of clients in a range of industry sectors. He is the author
of Apress books: SQL Server 2012 Data Integration Recipes, Pro Power BI Desktop (now
in its third edition), Business Intelligence with SQL Server Reporting Services, and High
Impact Data Visualization in Excel with Power View, 3D Maps, Get & Transform and
Power BI.
A graduate of Oxford University, Adam began his career in publishing before moving
into IT. Databases soon became a passion, and his experience in this arena ranges from
dBase to Oracle, and Access to MySQL, with occasional sorties into the world of DB2.
He is, however, most at home in the Microsoft universe when using SQL Server Analysis
Services, SQL Server Reporting Services, SQL Server Integration Services, and Power
BI—both on-premises and in Azure.
A fluent French speaker, Adam has worked in France and Switzerland for many years.
xiii
About the Technical Reviewer
Karine Aspin is a principal consultant with Calidra Ltd., a UK-based data and analytics
consultancy. A mathematics graduate of the Swiss Federal Institute of Technology,
Karine has worked at a range of IT companies including IBM Global Services.
xv
Acknowledgments
Writing a technical book can be a lonely occupation. So I am all the more grateful for
all the help and encouragement that I have received from so many fabulous friends and
colleagues.
First, my considerable thanks go to Jonathan Gennick, the commissioning editor
of this book. Throughout the publication process, Jonathan has been both a tower
of strength and an exemplary mentor. He has always been available to share his vast
experience selflessly and courteously.
Heartfelt thanks go to Jill Balzano, the Apress coordinating editor, for calmly
managing this book through the production process. She succeeded—once again—in
the well-nigh impossible task of making a potentially stress-filled trek into a pleasant
journey filled with light and humor. Her team also deserves much praise for their
efficiency under pressure.
I also owe a debt of gratitude to my wife, Karine, for her time and effort spent
reviewing this book. Being a technical reviewer is a thankless task, but I want to say a
heartfelt “thank you” to her for the range and depth of her comments and for picking up
so much that otherwise would have gone unnoticed. The book is a better one thanks to
her efforts.
My thanks also go to Ann Gemer Tuballa for her tireless and subtle work editing and
polishing the prose and to the team at SPi Global for the hours spent preparing the book
for publishing.
xvii
Introduction
Analytics has become one of the buzzwords that define an age. Managers want their staff
to deliver meaningful insight in seconds; users just want to do their jobs quickly and
well. Everyone wants to produce clear, telling, and accurate analysis with tools that are
intuitive and easy to use.
Microsoft recognized these trends and needs a few short years ago when they
extended Excel with an add-in called Power Query. Once a mere optional extension to
the world’s leading spreadsheet, Power Query is now a fundamental pillar of the Excel
toolkit. It allows a user to take data from a wide range of sources and transform them into
the base data that they can build on to add metrics, instant analyses, and KPIs to project
their insights.
With Power Query, the era of self-service data access and transformation has finally
arrived.
• Reshaping the data (the “data mashup” process) so that the resulting
data is in a form that can be used by Excel. Essentially, this means
ensuring that the data is in a coherent, structured, and complete
tabular format. This is the transform phase of ETL.
These three phases make up the data ingestion process. So it is worth taking a short
look at what makes up each one of them.
xix
Introduction
D
ata Transformation
Once you have established a connection to a data source, you may need to tweak the
data in some way. Indeed, you may even need to reshape it entirely. This is the data
mashup process—and it is the area where Power Query shines.
Power Query can carry out the simplest data transformation tasks to the most
complex data restructuring challenges in a few clicks. You can
• Filter source data so that you only load exactly the rows and columns
you need
xx
Introduction
• Join or split source tables to prepare a logical set of data tables for
each specific analytical requirement
This list merely scratches the surface of all that Power Query can do to mash up your
data. It is, without hyperbole, unbelievably powerful at transforming source data. Indeed,
it can carry out data ingestion and transformation tasks that used to be the preserve of
expensive products that required complex programming skills and powerful servers.
All of this can now be done using a code-free interface that assists you in taking the
messiest source data and delivering it to Excel as limpid tables of information ready to
work with. If you wish to become a Power Query super-user, then you can extend its
possibilities using the built-in M language.
• A worksheet: Power Query can place the data from each source
query into a separate worksheet. Once in a worksheet, it is perfectly
“normal” Excel data. From here on you can do what you want to
the data in Excel just as you normally would using all the Excel
techniques that you have learned over the years.
• The data model: Also referred to, often, as the Power Pivot data
model (which is the term that I prefer to use), this is an in-memory
data store. It can handle many more rows of data than Excel—tens
of millions in some cases—and is normally the basis for pivot table
output in Excel. When dealing with large source datasets, it is often
the ideal destination for data that you have accessed using Power
Query, as it is compressed in memory (and consequently takes up
less space when saved to disk) and can easily exceed the 1,048,576
row limit of Excel worksheets.
xxi
Introduction
The data model and Power Pivot are extensive subjects in their own right, and this
book will not be looking at either of them in detail.
• You can trigger manual data refreshes at any time—and these can be
total refreshes of every source connection in a workbook or refreshes
of a single source if you prefer.
So, as is the case for nearly all your Excel-based work, you are likely to build once
and use often.
xxii
Introduction
of the product. However, it will mean that certain aspects of the Excel interface that you
use to launch Power Query will be slightly different from those described in Chapters 1
through 5. These differences are essentially minor and should not present any
difficulties to experienced Excel users.
This is made possible due to the fact that Power Query is accessed using a separate
interface. It is called from inside Excel, but exists in its own parallel universe. This
ensures a consistent look and feel whatever the version of Excel that you are using. The
entry point into Power Query may change with Excel versions—but the product itself
remains the same. Just remember that the range of available data sources will depend on
the version of Excel that you are using. Some of the “enterprise-level” data sources are
only available in Pro and Enterprise subscriptions to Excel.
xxiii
Introduction
xxiv
CHAPTER 1
• Fast
• Decentralized
• Intuitive
• Interactive
• Delivery
1
© Adam Aspin 2020
A. Aspin, Data Mashup with Microsoft Excel Using Power Query and M,
https://doi.org/10.1007/978-1-4842-6018-0_1
Chapter 1 Using Power Query to Discover and Load Data into Excel
Using the techniques described in this book, you can discover and load data from
a multitude of external sources. You can then, quickly and intuitively, transform and
cleanse this raw data to make it structured and usable. Once ready for use, you can load
it into either Excel worksheets or the Power Pivot data model in Excel and start using the
tool you already know so well—Excel—to provide detailed analytics.
It follows that this book is written from the perspective of the user. Essentially it is
all about empowerment—letting users define their own requirements and satisfy their
own needs simply and efficiently by building on their existing skills. The amazing thing
is that you can do all of this using Excel without needing any other tools or utilities. Your
sources could be in many places and in many formats. Nonetheless, you need to access
them, sample them, select them, and, if necessary, transform or cleanse them in order to
deliver your analyses. All of this is enabled by Power Query.
Power Query
Power Query is one of the most recent additions to the Excel toolkit. Now fully integrated
into Excel, it allows you to discover, access, and consolidate information from varied
sources. Once your data is selected, cleansed, and transformed into a coherent table, you
can then place it in an Excel worksheet for detailed analysis or load it directly into Power
Pivot (the Excel data model), which is a natural repository for data when you want to
“slice and dice” it interactively.
Power Query allows you to do many things with source data, but the four main steps
are likely to be
• Shape data into the columns and records that suit your use cases.
There was a time when these processes required dedicated teams of IT specialists.
Well, not any more. With Power Query, you can mash up your own data so that it is the
way you want it and is ready to use as part of your self-service solution.
2
Chapter 1 Using Power Query to Discover and Load Data into Excel
• Data loading: Select the data you have examined and load a subset
into Power Query for shaping.
• Data modification: Modify the structure of each dataset that you have
imported.
Although I have outlined these three steps as if they are completely separate and
sequential, the reality is that they often blend into a single process. Indeed, there could
be many occasions when you will examine the data after it has been loaded into Excel—
or clean datasets before you load them. The core objective will, however, always remain
the same: find some data and then sample it in Power Query where you can tweak, clean,
and shape it before loading it into Excel.
This process could be described simplistically as “First, catch your data.” In the world
of data warehousing, the specialists call it ETL, which is short for Extract, Transform, and
Load. Despite the reassuring confidence that the acronym brings, this process is rarely
a smooth, logical progression through a clear-cut series of steps. The reality is often
far messier. You may often find yourself importing some data, cleaning it, importing
some more data from another source, combining the second dataset with the first one,
removing some rows and columns, and then repeating these operations, as well as many
others, several times over.
In this and the following few chapters, I will try to show you how the process can
work in practice using Power Query. I hope that this will make the various steps that
comprise an ETL process clearer. All I am asking is that you remain aware that the
range of options that Power Query includes make it a multifaceted and tremendously
capable tool. The science is to know which options to use. The art is to know when to
use them.
3
Chapter 1 Using Power Query to Discover and Load Data into Excel
3. Click Get Data. The Get Data popup menu will appear, as shown
in Figure 1-1.
4
Chapter 1 Using Power Query to Discover and Load Data into Excel
Figure 1-2. The Import Data dialog when loading data from an Excel workbook
5
Chapter 1 Using Power Query to Discover and Load Data into Excel
10. Click Load. The data will be loaded from the external Excel
workbook into a new worksheet inside the current workbook.
You will see the Excel window, like the one shown in Figure 1-4. The external data is
now an Excel table (named BaseData, as this was the name of the source data table). You
can see that the connection to the external workbook now appears on the right of the
Excel spreadsheet data in the new Queries & Connections pane. I will explain this new
element in a couple of pages once I have explained exactly why Power Query is such a
cool solution to data ingestion challenges.
6
Chapter 1 Using Power Query to Discover and Load Data into Excel
I imagine that loading this data took a few seconds at most. Yet you now have a
complete set of external data in Excel that is ready to be used for analysis and reporting.
However, for the moment, I would like to pause and explain exactly what you have seen
so far.
• Import multiple datasets from external data sources at the same time
7
Another Random Document on
Scribd Without Any Related Topics
holding up her hand, said, "Please, teacher, it means that the child
Jesus will have to be vaccinated."
The Rain and the Unjust.—A smart boy's composition on rain: "Rain
comes down from heaven on the just and the unjust, but mostly
upon the just, because the unjust have borrowed the umbrellas of
the just and have forgotten to return them."
Blurted Out the Truth.—A mother came with a truant one morning
and said, "Please excuse my boy, he has been ill the last fortnight."
The master said, "Very good, let him go to his class." The woman
then turned suddenly round and, seizing the lad by the jacket, gave
him a good shaking, saying at the same time, "I'll break every bone
in your dirty carcase if I've to come again and tell a pack of lies like
this for you."
The Point of View.—Overheard in infants playground. Little Girl:
"It's my grannie's funeral to-day. I've got threepence halfpenny and
a packet of sweets already."
She was Sorry.—A boy was absent from school. The teacher sent
to his home to ask the reason. The answer came back that he was
playing truant—sent by the mother. The next day the master made
inquiries, and found that the mother had sent this message because
she did not wish the boy's father, who was at home when the
messenger arrived, to know that she had kept him at home. During
this time the boy himself was hidden in a cupboard. A few weeks
after a similar occurrence happened, and a like answer was sent to
the master by the mother. The next day the boy appeared with the
following note: "Sir,—Sorry my boy was away yesterday, but he had
to go to the hospital and was kept, and I never sent him yesterday,
and I was sorry to tell a lye like last time. Please forgive me again.—
Mrs. ——."
"The Lavender."—"Deer Sur,—Plese let Jon go to the lavender wen
hever he wants as he as had some metson.—Yours truly, Mrs. ——."
"Your Grace."—A certain duchess, well known for the interest she
takes in the progress of education, once visited a school in L—— and
began to talk freely to a mite in the first standard. Several questions
were put to the child, to which the latter replied, "Yes, ma'am," or
"No, ma'am." The teacher of the class was annoyed at the frequency
with which the scholar used the word "ma'am," and at last said,
"You must say 'Your Grace.'" The duchess laughed heartily when the
child began, "Lord, make us truly thankful, &c."
"To keep milk from turning sour you should leave it in the cow."—
Jane, aged 10.
EXCUSED!
Teacher: "Oh! that's bad! What does the doctor say it is?"
Small Boy (in whose home there has just been a Double Event):
"By giving him only one baby at a time!"
Teacher: "Now, Frank, if you are not a good boy you won't go to
heaven."
Frank: "Oh, well! I went with father in Mr. B.'s yacht, and I went
to the circus. A little boy can't expect to go everywhere!"
H.M. Inspector: "If I dig right down through the earth, where shall
I come to?"
JUVENILE COMPLAINTS.
"New Roger"—Neuralgia.
"Scarlet Concertina"—Scarletina.
Teacher: "Now, little ones, you can take off your warm overcoats.
Can the bear take his off?"
Delighted Little One: "Because only God knows where the buttons
are!"
"The anshent Britons painted themselves all over blue with the
juce obtained from the tree o nolledge of Good and Evil."—From
Harry's Composition Exercise.
Boy (reading): "She threw herself into the river. Her husband,
horror-stricken, rushed to the bank——"
Tommy is in the Second Standard, and aged eight. The class was
asked to write a short letter to teacher describing their doings on
Guy Fawkes night. He began in right good style with the orthodox
"Dear Miss C——." Everything went quietly till the close. It was then
that Tommy shone. He wound up: "I remain, your loving son in who
I am well pleased,——"
"Manners is a very good thing when you are trying for a
situation."—From James Henry's Composition.
The essay was upon "Dreams." One boy who has a great dread of
arithmetic dreamt he was in heaven, where his teacher kept calling
out, "No sums right, stand up!"
James: "Yes, teacher. I knew they would be. Father would help
me!"
THE END.
PRINTING OFFICE OF THE PUBLISHERS
Bristol:
J. W. Arrowsmith.
London:
Simpkin, Marshall, Hamilton, Kent & Co. Ltd.
ARROWSMITH'S
POCKET
SERIES.
Fcap. 8vo, Leather, Gilt top and back, 3/6 net.
" Cloth "" 2/6 net.
The Westcotes.
By Sir Arthur Quiller-Couch.
Sophy of Kravonia.
By Anthony Hope.
A Selection of
Arrowsmith's 6/- Books.
Woodhays. By E. F. Pierce.
The illustrations have been moved so that they do not break up paragraphs
and so that they are next to the text they illustrate. Thus the page number of
the illustration might not match the page number in the List of Illustrations, and
the order of illustrations may not be the same in the List of Illustrations and in
the book.
On page 71, a single quotation mark after "Cast out a devil, sir!" was
replaced with a double quotation mark.
On page 119, a quotation mark was added before "is your favorite writer".
On page 120, a single quotation mark was added after "their lives".
On page 129, a single quotation mark after "sweet song" was replaced with
a double quotation mark.
On page 132, a single quotation mark before "How many" was replaced with
a double quotation mark.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com