Professional Documents
Culture Documents
Omid Motamedisedeh
The Ultimate Guide to Functions in Power Query: Turn Raw Data into
Actionable Insights
Omid Motamedisedeh
Brisbane, QLD, Australia
Acknowledgments�����������������������������������������������������������������������������xxi
Introduction�������������������������������������������������������������������������������������xxiii
v
Table of Contents
Table��������������������������������������������������������������������������������������������������������������31
Function���������������������������������������������������������������������������������������������������������31
Type Conversion��������������������������������������������������������������������������������������������������32
Converting Values to the Number Format������������������������������������������������������33
Converting Values to the Text Format������������������������������������������������������������34
Converting Values to the Date and Time Format�������������������������������������������35
Converting Values to the Record Format�������������������������������������������������������35
Conclusion����������������������������������������������������������������������������������������������������������36
vi
Table of Contents
vii
Table of Contents
Date.Day��������������������������������������������������������������������������������������������������������94
Date.DayOfWeek��������������������������������������������������������������������������������������������94
Date.DayOfWeekName�����������������������������������������������������������������������������������95
Date.WeekOfMonth����������������������������������������������������������������������������������������95
Date.WeekOfYear�������������������������������������������������������������������������������������������96
Date.Month����������������������������������������������������������������������������������������������������96
Date.MonthName�������������������������������������������������������������������������������������������97
Date.DayOfYear����������������������������������������������������������������������������������������������97
Date.Year�������������������������������������������������������������������������������������������������������98
Summary������������������������������������������������������������������������������������������������������������98
viii
Table of Contents
List.Select����������������������������������������������������������������������������������������������������122
List.FindText������������������������������������������������������������������������������������������������123
Removing Values in a List���������������������������������������������������������������������������������124
List.RemoveNull�������������������������������������������������������������������������������������������124
List.Distinct��������������������������������������������������������������������������������������������������125
List.RemoveFirsN and List.RemoveLastN����������������������������������������������������126
List.RemoveRange���������������������������������������������������������������������������������������127
List.RemoveItems����������������������������������������������������������������������������������������128
List.Skip�������������������������������������������������������������������������������������������������������129
List.Alternate�����������������������������������������������������������������������������������������������129
List Merging������������������������������������������������������������������������������������������������������131
List.Combine������������������������������������������������������������������������������������������������131
List.InsertRange������������������������������������������������������������������������������������������132
List.Zip���������������������������������������������������������������������������������������������������������133
List.Union�����������������������������������������������������������������������������������������������������133
List.Intersect������������������������������������������������������������������������������������������������134
List.Difference���������������������������������������������������������������������������������������������135
Mathematical Calculations on the Data of a List����������������������������������������������136
List Information Functions��������������������������������������������������������������������������������139
List.IsEmpty�������������������������������������������������������������������������������������������������140
List.IsDistinct�����������������������������������������������������������������������������������������������140
List.Contains������������������������������������������������������������������������������������������������141
List.ContainsAll��������������������������������������������������������������������������������������������142
List.ContainsAny������������������������������������������������������������������������������������������143
List.AllTrue���������������������������������������������������������������������������������������������������144
List.AnyTrue�������������������������������������������������������������������������������������������������144
ix
Table of Contents
Positions in a List����������������������������������������������������������������������������������������������144
List.Positions�����������������������������������������������������������������������������������������������145
List.PositionOf���������������������������������������������������������������������������������������������145
List.PositionOfAny����������������������������������������������������������������������������������������147
Replacing and Transforming Values������������������������������������������������������������������148
List.ReplaceValue����������������������������������������������������������������������������������������148
List.ReplaceMatchingItems�������������������������������������������������������������������������149
List.ReplaceRange���������������������������������������������������������������������������������������151
List.Transform����������������������������������������������������������������������������������������������152
List.TransformMany�������������������������������������������������������������������������������������153
Other Functions�������������������������������������������������������������������������������������������������154
List.Single����������������������������������������������������������������������������������������������������154
List.SingleOrDefault�������������������������������������������������������������������������������������154
List.Repeat���������������������������������������������������������������������������������������������������155
List.Split�������������������������������������������������������������������������������������������������������156
Summary����������������������������������������������������������������������������������������������������������157
Chapter 7: Records���������������������������������������������������������������������������159
Defining a Record���������������������������������������������������������������������������������������������159
Record Properties���������������������������������������������������������������������������������������������162
Record.FieldCount���������������������������������������������������������������������������������������162
Record.FieldNames�������������������������������������������������������������������������������������163
Record.FieldValues��������������������������������������������������������������������������������������163
Record.ToList�����������������������������������������������������������������������������������������������164
Record.Field������������������������������������������������������������������������������������������������164
Record.FieldOrDefault���������������������������������������������������������������������������������165
Record.HasFields�����������������������������������������������������������������������������������������166
x
Table of Contents
Record Correction���������������������������������������������������������������������������������������������167
Record.AddField������������������������������������������������������������������������������������������167
Record.Combine������������������������������������������������������������������������������������������168
Record.SelectFields�������������������������������������������������������������������������������������168
Record.RemoveFields����������������������������������������������������������������������������������170
Record.RenameFields����������������������������������������������������������������������������������172
Record.ReorderFields����������������������������������������������������������������������������������173
Record.TransformFields�������������������������������������������������������������������������������174
Record Conversion��������������������������������������������������������������������������������������������175
Record.FromList������������������������������������������������������������������������������������������175
Record.FromTable����������������������������������������������������������������������������������������176
Record.ToTable��������������������������������������������������������������������������������������������177
Summary����������������������������������������������������������������������������������������������������������177
Chapter 8: Tables������������������������������������������������������������������������������179
Creating a Table������������������������������������������������������������������������������������������������180
Table.FromColumns�������������������������������������������������������������������������������������180
Table.FromRows������������������������������������������������������������������������������������������182
Table.FromRecords��������������������������������������������������������������������������������������185
Table.FromValue������������������������������������������������������������������������������������������187
Table Conversion�����������������������������������������������������������������������������������������������189
Table.ToRecords�������������������������������������������������������������������������������������������190
Table.ToColumns������������������������������������������������������������������������������������������190
Table.ToRows�����������������������������������������������������������������������������������������������191
Table.ToList��������������������������������������������������������������������������������������������������192
Table.Column�����������������������������������������������������������������������������������������������193
Table.TransformRows����������������������������������������������������������������������������������194
Table.Split����������������������������������������������������������������������������������������������������195
Table.SplitAt�������������������������������������������������������������������������������������������������196
xi
Table of Contents
Information��������������������������������������������������������������������������������������������������������197
Selecting Table Rows����������������������������������������������������������������������������������������200
Table.FirstValue�������������������������������������������������������������������������������������������201
Table.First and Table.Last����������������������������������������������������������������������������201
Table.FirstN and Table.LastN������������������������������������������������������������������������202
Table.Max and Table.Min�����������������������������������������������������������������������������204
Table.MaxN and Table.MinN�������������������������������������������������������������������������206
Table.Range�������������������������������������������������������������������������������������������������208
Table.SelectRows����������������������������������������������������������������������������������������209
Table.SelectRowsWithErrors������������������������������������������������������������������������212
Deleting Table Rows������������������������������������������������������������������������������������������214
Table.RemoveFirstN and Table.RemoveLastN����������������������������������������������214
Table.Distinct�����������������������������������������������������������������������������������������������217
Table.Skip����������������������������������������������������������������������������������������������������219
Table.RemoveRows��������������������������������������������������������������������������������������221
Table.AlternateRows������������������������������������������������������������������������������������222
Table.RemoveRowsWithErrors���������������������������������������������������������������������224
Table.RemoveMatchingRows�����������������������������������������������������������������������225
Insert and Replace Table Rows�������������������������������������������������������������������������227
Table.InsertRows�����������������������������������������������������������������������������������������228
Table.ReplaceRows��������������������������������������������������������������������������������������229
Table.ReplaceMatchingRows�����������������������������������������������������������������������231
Table.Repeat������������������������������������������������������������������������������������������������232
Order of rows����������������������������������������������������������������������������������������������������234
Table.ReverseRows�������������������������������������������������������������������������������������234
Table.Sort�����������������������������������������������������������������������������������������������������235
Checking a Condition in All Rows����������������������������������������������������������������������238
xii
Table of Contents
Table.IsDistinct��������������������������������������������������������������������������������������������238
Table.MatchesAllRows���������������������������������������������������������������������������������239
Table.MatchesAnyRows�������������������������������������������������������������������������������241
Table.Contains���������������������������������������������������������������������������������������������242
Table.ContainsAll and Table.ContainsAny����������������������������������������������������244
Table.SingleRow������������������������������������������������������������������������������������������245
Column Names��������������������������������������������������������������������������������������������������246
Table.ColumnNames������������������������������������������������������������������������������������246
Table.DemoteHeaders����������������������������������������������������������������������������������246
Table.PromoteHeaders���������������������������������������������������������������������������������247
Table.HasColumns���������������������������������������������������������������������������������������249
Table.ColumnsOfType����������������������������������������������������������������������������������250
Table.PrefixColumns������������������������������������������������������������������������������������251
Table.RenameColumns��������������������������������������������������������������������������������252
Modifing columns���������������������������������������������������������������������������������������������255
Table.RemoveColumns��������������������������������������������������������������������������������256
Table.SelectColumns�����������������������������������������������������������������������������������259
Table.DuplicateColumn��������������������������������������������������������������������������������263
Table.TransformColumnTypes����������������������������������������������������������������������265
Table.TransformColumns�����������������������������������������������������������������������������267
Table.AddIndexColumn��������������������������������������������������������������������������������271
Table.AddColumn�����������������������������������������������������������������������������������������274
Table.AddRankColumn���������������������������������������������������������������������������������277
Table.SplitColumn����������������������������������������������������������������������������������������281
Table.CombineColumns�������������������������������������������������������������������������������285
Table.CombineColumnsToRecord����������������������������������������������������������������288
Table.ReorderColumns���������������������������������������������������������������������������������290
Table.Pivot���������������������������������������������������������������������������������������������������291
xiii
Table of Contents
Table.Unpivot�����������������������������������������������������������������������������������������������294
Table.Group��������������������������������������������������������������������������������������������������297
Table.Transpose�������������������������������������������������������������������������������������������301
Combining Tables����������������������������������������������������������������������������������������������303
Table.Combine���������������������������������������������������������������������������������������������303
Table.Join����������������������������������������������������������������������������������������������������308
Table.NestedJoin�����������������������������������������������������������������������������������������317
Expanding Columns������������������������������������������������������������������������������������������319
Table.ExpandListColumn������������������������������������������������������������������������������320
Table.ExpandRecordColumn������������������������������������������������������������������������322
Table.ExpandTableColumn���������������������������������������������������������������������������326
Table.AggregateTableColumn����������������������������������������������������������������������329
Replacing Column Values����������������������������������������������������������������������������������330
Table.FillDown and Table.FillUp�������������������������������������������������������������������331
Table.ReplaceErrorValues����������������������������������������������������������������������������334
Table.ReplaceValue��������������������������������������������������������������������������������������337
Finding a Value in a Table����������������������������������������������������������������������������������340
Table.FindText����������������������������������������������������������������������������������������������340
Table.PositionOf�������������������������������������������������������������������������������������������341
Table.PositionOfAny�������������������������������������������������������������������������������������344
Summary����������������������������������������������������������������������������������������������������������345
xiv
Table of Contents
Excel.CurrentWorkbook�������������������������������������������������������������������������������������357
Summary����������������������������������������������������������������������������������������������������������357
Index�������������������������������������������������������������������������������������������������383
xv
About the Author
Omid Motamedisedeh is a freelance data and
business intelligence analyst with a PhD in
Industrial Engineering. He’s currently working
towards his second PhD at Queensland
University of Technology. Omid is the author
of several articles in industry journals (Electric
Power Systems Research, Journal of Building
Engineering, Energy, Neural Computing and
Applications, and others), and seven books (all
in Farsi) namely Managing Data Entry in Excel by Data Validation, Data
Analysis by Excel’s Pivot Table, Power Query as The Magic of Excel, 222
Most Useful Functions in Excel 2016, Useful Excel Functions in Excel 2019,
Reference of Functions in Excel 2021, and From Drawing Charts to Creating
Dashboards in Excel 2016.
xvii
About the Technical Reviewer
Bo Rydobon (a.k.a. Excel Wizard) is a Microsoft Excel expert and YouTuber
from Thailand who is known for his speed and mastery of Excel. He is also
the creator of the Excel Wizard YouTube channel, where he shares tips and
tricks on how to use advanced dynamic arrays. He actively contributes
on Excelforum.com and became a Top 5 reputation within a few years.
His participation in the Excel BI LinkedIn Excel Challenge drew notable
attention due to his impressive response. In 2022, Bo Rydobon won the
Excel Esports Speedrun organized by the Financial Modeling World Cup.
Bo Rydobon is an inspiration to Excel users all over the world.
He shows that anyone can learn Excel and become an expert, regardless of
their background or experience.
xix
Acknowledgments
I would like to express my sincere gratitude to the individuals who have
played an indispensable role in supporting me throughout the process
of writing this book. My appreciation extends to both those within my
professional circle and those who hold a personal place in my life.
First and foremost, I extend heartfelt thanks to Faranak, whose
unwavering belief in me and encouragement provided the catalyst for
embarking on this writing journey.
I am equally grateful to Bo Rydobon, my esteemed technical reviewer,
whose invaluable insights and motivating feedback have significantly
enriched the quality of this work.
Furthermore, I wish to extend my thanks to the Apress team, including
Susan McDermott (Editorial Director), Shobana Srinivasan (Book
Coordinator), and Shaul Elson (Editorial Manager), for their commendable
professionalism and collaborative approach. Their contributions have
transformed working with Apress into a truly gratifying experience.
Lastly, my profound and enduring appreciation goes to Professor
Hamid Reza Irani, who imparted foundational knowledge of Excel during
my undergraduate years, and to Mike Girvin, a cherished Excel mentor.
Mike's prolific Excel tips shared on the ExcelIsFun YouTube channel have
been a wellspring of learning for all Excel fans like me.
xxi
Introduction
In today's data-driven landscape, the ability to seamlessly transform raw
data into meaningful insights is a skill of paramount importance. The
Ultimate Guide to Functions in Power Query stands as a beacon for Excel
and Power BI enthusiasts, equipping them with the tools to unlock the full
potential of their data manipulation endeavors.
In this comprehensive guide, you will delve into the world of Power
Query functions, the building blocks that empower users to effortlessly
manipulate, cleanse, and refine their data. Whether you're a seasoned
data professional or a novice user, this book is designed to elevate your
proficiency in harnessing the capabilities of Power Query functions,
ultimately enabling you to convert seemingly complex datasets into
actionable insights.
Join me on a journey through the intricacies of Power Query functions
as I demystify their functionalities, explore real-world use cases, and
provide step-by-step guidance on their application. With a meticulous
balance of theory and hands-on practice, The Ultimate Guide to Functions
in Power Query is not just a book; it's your indispensable companion in
mastering the art of data transformation.
Chapters include
xxiii
Introduction
xxiv
Introduction
xxv
CHAPTER 1
Introduction to
Power Query
In the dynamic landscape of modern data analysis, the ability to turn
raw information into meaningful insights is a cornerstone of success.
Welcome to the world of Power Query, an invaluable tool that empowers
data professionals to tame, reshape, and amplify data, unveiling its hidden
potential. This chapter serves as your gateway to understanding the
essence of Power Query, its significance, and the journey you are about to
embark upon.
In a data-driven era, information is abundant, sprawling across
spreadsheets, databases, cloud storage, and beyond. But this information
is often disparate, inconsistent, and unstructured. This is where Power
Query steps in as a guiding light, enabling you to navigate through
these complexities and emerge with knowledge that fuels smarter
decision-making.
Your exploration begins with a foundational understanding of what
Power Query truly is: a powerful data transformation tool embedded
within familiar environments such as Microsoft Excel and Power BI. I’ll
unveil its intuitive interface, its versatile functions, and its innate ability to
streamline even the most intricate data manipulation tasks.
This tool was introduced as an add-in for Excel 2010 and later for 2013.
In these versions, by installing the add-in, a new tab called Power Query
was added to Excel, as shown in Figures 1-1 and 1-2.
2
Chapter 1 Introduction to Power Query
In Excel 2016 and later, this tool was added to the main Excel
commands in the Data tab. In Excel 2021 and also 365, the commands
related to Power Query are available in the Get & Transform Data group
under the Data tab, and users can perform data extraction, modification,
and loading processes using these commands (Figure 1-3).
In Power BI, the commands related to Power Query are located in the
Data section of the Home tab, as shown in Figure 1-4.
3
Chapter 1 Introduction to Power Query
4
Chapter 1 Introduction to Power Query
As you can see in Figure 1-5, different options are provided to extract
the tables from different data sources. To extract values from another Excel
file, select From File, and then From Excel File. The window shown in
Figure 1-6 will appear and you can navigate the desired Excel file.
5
Chapter 1 Introduction to Power Query
You’ll see a list of all tables and sheets in the selected Excel file on the
left side of this window. Depending on the user’s needs, one or more tables
can be selected and called in Power Query for the cleaning process. In this
example, by selecting the 05-Inventory table and selecting the Transform
button, the data is loaded in Power Query, as shown in Figure 1-8. (Now
the data extraction process is completed.)
6
Chapter 1 Introduction to Power Query
Now you can perform the cleaning process via various commands. For
example, to remove the first row of the table (empty row), simply select the
Remove Top Rows command from the Reduce Rows section of the Home
tab. The window shown in Figure 1-9 will appear to determine the number
of rows that you want to remove from the top of the table.
7
Chapter 1 Introduction to Power Query
Enter 1 in the field and confirm it. As you can see in Figure 1-10, the
first row of the table gets removed.
In the next step, to replace the column headers with the first row,
select the Use first row as header command from the Transform tab. See
Figure 1-11 for the result.
8
Chapter 1 Introduction to Power Query
Figure 1-11. Replacing column headers with the first data row
9
Chapter 1 Introduction to Power Query
10
Chapter 1 Introduction to Power Query
11
Chapter 1 Introduction to Power Query
You’ve reached your desired result, so at this stage, the data cleaning
process in this example is complete (the data cleaning process is not
limited to the mentioned commands and will be explained further). For
the final step, load the data as a table in Excel (or Power Pivot, which is
considered the data model). Select the Close & Load To command from
the File tab, and the loading window will appear as shown in Figure 1-15.
In this window, you can specify how the final table should be loaded
into Excel. If you select Table, the result will be visible in Excel, as seen in
Figure 1-16.
12
Chapter 1 Introduction to Power Query
So, in this example, values from other Excel files were extracted,
cleaned, and finally loaded as a table in the Excel file.
13
Chapter 1 Introduction to Power Query
In this window, by selecting the desired table(s) from the left window
and selecting the Transform Data command, the data will be transferred to
Power Query, as you can see in Figure 1-18.
14
Chapter 1 Introduction to Power Query
15
Chapter 1 Introduction to Power Query
M Code
To reopen the Power Query window and modify the created query in the
Excel file, the Queries & Connections mode from the Data section of the
Home tab in the Excel should be activated. A list of active queries will be
16
Chapter 1 Introduction to Power Query
shown in the Queries and Connections section (Figure 1-20). The queries
can be modified by right-clicking them and selecting the Edit option.
The result of query will be shown, as you can see in Figure 1-21.
17
Chapter 1 Introduction to Power Query
The query can be modified step by step in the Applied Step section or
can be modified altogether by selecting the Advanced Editor command in
the Home tab, which will lead to the result shown in Figure 1-22.
The Advanced Editor window contains all the steps taken in extracting
and cleaning the data, written in the M language, which is shown below.
(If it is not clear to you, don’t worry. You are going to learn about these
commands and be able to write them yourself by the end of this book)
Let
Source = Excel.Workbook(File.Contents("C:\Users\omid_\
OneDrive\Desktop\Data\05-Inventory.xlsx"), null, true),
#"06-Inventory_Sheet" = Source{[Item="06-
Inventory",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"06-Inventory_
Sheet", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted
Headers",{{"last update on 2018/02/19", type text},
{"Column2", type text}, {"Column3", type any}}),
#"Removed Top Rows" = Table.Skip(#"Changed Type",1),
18
Chapter 1 Introduction to Power Query
In this example, the Table.Skip function receives the table with the
name #"Changed Type" (which was calculated in the previous step) and
removes the first row. Then it displays the new table as output. Therefore,
the value of the variable #"Removed Top Rows" is equal to a table.
19
Chapter 1 Introduction to Power Query
Table.Skip(
table as table,
optional countOrCondition as any
) as table
This function has two inputs (separated by a comma). The first input
is a table as table, which means that the first input is in the table format
which is called Table (the input type is specified after the as), and the
second input is optional (because of the use of the word Optional) and
is named countOrCondition with a format of any. Finally, since the table
expression is registered at the end of the function, the output of this
function is always a table.
In another line of this code, the variable #"Changed Type2" is defined
as follows:
20
Chapter 1 Introduction to Power Query
Conclusion
In this chapter, you were introduced to Power Query, an essential tool
for data transformation and manipulation in various data analysis and
visualization contexts. This is the beginning of your Power Query journey.
In this chapter, a simple example of a Power Query application was
provided so you could get familiar with the basic features of Power Query
and the M language. You also learned the role of the M language in data
transformations. You also saw the use of commands to clean the values in
a table. In the rest of this book, all of the main functions will be explained
in depth.
The next chapter delves deeper into the types of data in Power Query
including, null, logical values, number, text, list, records, and binary.
21
CHAPTER 2
Data Types
Like any other software, Power Query supports different data types
(formats) and provides a wide range of functions for modifying values
based on their types. Power Query supports simple data types such as
numbers, text, and time/date as well as complex data types like lists, tables,
and binary. This chapter focuses on understanding the fundamental data
types used in Power Query and their characteristics plus handling type
conversions. By the end of this chapter, you will have a solid understanding
of how to effectively manage and manipulate different data types within
Power Query, setting the stage for more advanced data transformation and
analysis in subsequent chapters.
=Text.Start(“Hello”,3) “Hel”
=Text.Start(“1232”,2) “12”
=Text.Start(1232,2) Error
Null Null
true/false Logical
0 1 -1 1.5 2.3e-5 Number
#time(09,15,00) Time
#date(2013,02,26) Date
#datetime(2013,02,26, 09,15,00) DateTime
#datetimezone(2013,02,26, 09,15,00, 09,00) DateTimeZone
#duration(0,1,30,0) Duration
“hello” Text
#binary(“AQID”) Binary
{1, 2, 3} List
[ A = 1, B = 2 ] Record
#table({“X”,“Y”},{{0,1},{1,0}}) Table
(x) => x + 1 Function
type { number } type table [ A = any, B = text ] Type
24
Chapter 2 Data Types
Null
The value of null is used instead of missing values in Power Query and is
defined as null. Some mathematical operations can be done on the null
values. Assuming that the variable x is equal to null and y is a none null
value, various mathematical operations and their results are shown in
Table 2-3.
x>y null
x >= y null
x<y null
x <= y null
x=y null
x <> y null
x ?? y y
y ?? x y
Logical Values
The logical value type of data, with the symbol of , includes two states:
true or false. To compare the values in this group, true can be considered
equivalent to the number 1 and false can be considered equivalent to the
number 0.
Generally, logical values are obtained by comparing one value with
another (for example, 2>3) or the output of information functions such as
Number.IsOdd.
25
Another random document with
no related content on Scribd:
The shaft, however, was never built. Screw propulsion was just
coming into use; the design of the vessel was changed, and the
whole scheme lapsed. A year or so later, M. Schneider, the French
iron master of Creuzot, and his engineer, M. Bourdon, visited
Bridgewater while Nasmyth happened to be away. Mr. Gaskell, after
taking them about the plant, showed them the Scheme Book and
pointed out the sketch of the hammer, telling them of the purpose for
which it was intended. They were impressed with it and took careful
notes and sketches of its details. Nasmyth was informed of their visit
upon his return, but knew nothing of their having taken sketches of
the hammer.
In 1842 Nasmyth visited France, and was cordially received at
Creuzot and shown about the works. “On entering,” he writes, “one
of the things that particularly struck me was the excellence of a large
wrought-iron marine engine single crank, forged with a remarkable
degree of exactness in its general form. I observed also that the
large eye of the crank had been punched and drifted with
extraordinary smoothness and truth. I inquired of M. Bourdon ‘how
that crank had been forged?’ His immediate reply was, ‘It was forged
by your steam hammer!’... He told me ... that he had taken careful
notes and sketches, and that among the first things he did after his
return to Creuzot was to put in hand the necessary work for the
erection of a steam hammer.... M. Bourdon conducted me to the
forge department of the works, that I might, as he said, ‘see my own
child’; and there it was, in truth—a thumping child of my brain.”[100]
Fortunately it was still time to save his patent rights. He moved
rapidly and in June, 1842, two months after his visit to Creuzot, a
patent was obtained.[101]. The steam hammer soon found its way
into all the large shops of the world and greatly increased Nasmyth’s
already comfortable fortune. Nasmyth transferred his United States
patent to S. V. Merrick of Philadelphia, who introduced the hammer
into the American iron works.
[100] Ibid., pp. 246-247. The self-acting valve motion for the steam
hammer was invented by Mr. Wilson, when Nasmyth was absent on
business. Wilson was manager at Patricroft and later became a partner. It
was much used for a time but with the advent of balanced piston-valves the
hand-operated gear supplanted it. Nasmyth’s invention of the hammer was
denied by M. Schneider in 1871. For fuller discussion of the history of this
hammer see London Engineer, May 16, 1890, and a pamphlet by T. S.
Rowlandson, entitled “History of the Steam Hammer.” Manchester, 1866.
[101] No. 9382, June 9, 1842.
The first step, the production of true plane surfaces, made while
he was at Maudslay’s, was, we are told, a self-imposed task. The
method of producing these, three at a time, is generally credited to
Whitworth. We have already quoted Nasmyth’s statement that the
method was in use at Maudslay’s and that it was “a very old
mechanical dodge.” While this is probably true, Whitworth
contributed something to the method, which very greatly increased
the accuracy of the product. The writer is inclined to believe that that
element was the substitution of hand scraping for grinding in the final
finishing operations. Whitworth’s paper, read before the British
Association for the Advancement of Science at Glasgow in 1840,
indicates this, although it does not say so directly. In this paper he
specifically points out the reason why planes should not be finished
by grinding them together with abrasive powder in between; namely,
that the action of the grinding powder was under no control, that
there was no means of securing its equal diffusion or modifying its
application and localizing its action to the particular spot which
needed it. Holtzapffel confirms this view, saying, in 1847: “The entire
process of grinding, although apparently good, is so fraught with
uncertainty, that accurate mechanicians have long agreed that the
less grinding that is employed on rectilinear works the better, and Mr.
Whitworth has recently shown in the most satisfactory manner,[103]
that in such works grinding is entirely unnecessary, and may, with
the greatest advantage be dispensed with, as the further prosecution
of the scraping process is quite sufficient to lead to the limit of
attainable accuracy.... The author’s previous experience had so fully
prepared him for admission of the soundness of these views, that in
his own workshop he immediately adopted the suggestion of
accomplishing all accurate rectilinear works by the continuance of
scraping, to the entire exclusion of grinding.”[104]
[103] Referring to the paper before the British Association, 1840.
[104] “Turning and Mechanical Manipulation,” Vol. II, p. 872.
Under the act of 1750, the importation rose to about 3250 tons, 94
per cent of which still came from Maryland, Virginia and
Pennsylvania. Practically all the iron produced in New England was
used there, for, despite the repressive measures from the mother
country, small local manufacturing enterprises, “moonshine iron
works,” were constantly cropping up. The iron supply of New
England came at first from the bog ores in eastern Massachusetts
and Rhode Island. By 1730-1760 better mines were opened at
Salisbury, Conn., and in Orange County, New York, so that the
production of iron in the bog-ore regions gradually dwindled.
The Revolution terminated British legislative control over the trade
and manufactures of America. The war itself furnished a market for
supplies for the army, and the manufacture of cannon and guns was
active. Many of these factories were ruined by the flood of imports
which followed the Revolution. In 1789 the present Federal
Government replaced the ineffective Confederation, which had left to
the separate states the duty of protecting their manufacturing
interests, and a tariff was placed upon manufactured articles. Freed
from the old restrictions, and with foreign competition largely
precluded, manufacturing industries began to spring up on every
hand.
A third cause contributed to rapid development at this time. An
enormous production of cotton followed Whitney’s invention of the
cotton gin in 1792, and the South, which had never been a
manufacturing community, furnished both a source of supply and a
rich market, easily accessible by coastwise trade. The beginnings of
New England’s manufacturing industries are closely identified with
the rise of the American cotton crop, and most of the first machine
shops were developed to manufacture textile machinery.
England, who seems to have blundered whenever she legislated
on early American trade, made one more serious mistake. In 1785
Parliament passed a stringent law, with severe penalties, to stop the
emigration of all mechanics and workmen in iron and steel
manufactures, and to prevent not only the exportation of every
description of tool, engine or machine, or parts of a machine used in
making and working up iron and other materials, but even the
models and plans of such machinery.[113] England was then the most
advanced of all countries in the production of engines, tools and
textile machinery, and it was hoped by this act that manufacturing
might be kept there. It had the opposite effect so far as America was
concerned. It was inevitable that mechanics, such as Samuel Slater
and William Crompton, should get away, and with them, ideas. The
act only stimulated a race of skillful mechanics in America to
independent development of machine tools, textile machinery, and
the like. America, instead of buying her machinery from England as
she would naturally have done, proceeded to make it herself.
[113] Ibid., Vol. I, p. 630.
From the little forge and foundry started at Lynn, there is no break
in the spread of iron manufacturing in this country. The forge was
located on the lands of Thomas Hudson, of the same family as
Hendrick Hudson, the explorer. Jenks was “the first founder who
worked in brass and iron on the western continent. By his hands, the
first models were made and the first castings taken of many
domestic implements and iron tools.”[115] The very first casting is said
to have been an iron quart pot.
[115] Lewis: “History of Lynn.”
For many years the colonial records refer to his various activities.
He made the dies for the early Massachusetts coinage, including the
famous pine-tree shilling.[116] In 1646 the General Court of
Massachusetts resolved that “In answer to the peticon of Joseph
Jenckes, for liberty to make experience of his abilityes and
Inventions for ye making of Engines for mills to go with water for ye
more speedy despatch of work than formerly, and mills for ye making
of Sithes and other Edged tools, with a new invented Sawe-Mill, that
things may be afforded cheaper than formerly, and that for fourteen
yeeres without disturbance by any others setting up like inventions;
... this peticon is granted.”[117] In 1655 he was granted a
Massachusetts patent for scythes, his improvement consisting of
making them long and thin, instead of short and thick, as in the old
English scythe, and of welding a bar of iron upon the back to
strengthen it, which later became the universal practice,[118] and no
radical change has been made in the blade of this implement since
his day. He built for the town of Boston the first fire engine used in
this country, and also made machines for drawing wire. Jenks seems
to have also been interested in another iron works started at
Braintree between 1645 and 1650.
[116] Weeden: “Economic and Social History of New England,” Vol. I, p.
191.
[117] Goodrich: “History of Pawtucket,” p. 17.
[118] Weeden, Vol. I, p. 184. Bishop, Vol. I, p. 477.