Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,000 --> 00:00:02,000
Instructor: Up next we've got appending queries,
2
00:00:02,000 --> 00:00:04,000
and you'll find the appending queries tool
3
00:00:04,000 --> 00:00:07,000
right under Merge in the Home tab of the query editor.
4
00:00:07,000 --> 00:00:09,000
When you click that button,
5
00:00:09,000 --> 00:00:11,000
you'll see this really simple dialogue box
6
00:00:11,000 --> 00:00:13,000
where you can choose to append either two tables
7
00:00:13,000 --> 00:00:16,000
or three or more together.
8
00:00:16,000 --> 00:00:18,000
Now, both merging and appending are similar
9
00:00:18,000 --> 00:00:21,000
in that they're adding information to an existing table,
10
00:00:21,000 --> 00:00:23,000
but they're different in that merging is adding columns
11
00:00:23,000 --> 00:00:26,000
and appending is stacking rows.
12
00:00:26,000 --> 00:00:29,000
So basically, appending queries allows you
13
00:00:29,000 --> 00:00:31,000
to combine or stack two tables,
14
00:00:31,000 --> 00:00:34,000
assuming that they share the exact same column structure
15
00:00:34,000 --> 00:00:35,000
and data types.
16
00:00:35,000 --> 00:00:38,000
So that's super important to keep in mind.
17
00:00:38,000 --> 00:00:40,000
Same structure and same data types.
18
00:00:40,000 --> 00:00:43,000
So in this case that we're looking at here,
19
00:00:43,000 --> 00:00:45,000
we're appending two tables together.
20
00:00:45,000 --> 00:00:47,000
There are two different AdventureWorks sales tables,
21
00:00:47,000 --> 00:00:50,000
one from 2020 and one from 2021,
22
00:00:50,000 --> 00:00:52,000
and it's a valid append
23
00:00:52,000 --> 00:00:55,000
since they both share identical table structures.
24
00:00:55,000 --> 00:00:57,000
So just like we've talked about merging
25
00:00:57,000 --> 00:01:00,000
makes tables wider by adding more columns,
26
00:01:00,000 --> 00:01:04,000
appending makes tables taller by adding more rows.
27
00:01:04,000 --> 00:01:06,000
So a pro tip here that I wanna share with you
28
00:01:06,000 --> 00:01:08,000
and we'll actually dive into this
29
00:01:08,000 --> 00:01:10,000
with the demo in the next lecture
30
00:01:10,000 --> 00:01:13,000
is to use the folder option from the Get Data menu.
31
00:01:13,000 --> 00:01:16,000
And what this lets you do is actually point Power BI
32
00:01:16,000 --> 00:01:19,000
to a folder containing as many files as you choose,
33
00:01:19,000 --> 00:01:21,000
which allows you to append all of them at once,
34
00:01:21,000 --> 00:01:24,000
assuming that they share that same structure.
35
00:01:24,000 --> 00:01:26,000
And the beauty of it is that over time
36
00:01:26,000 --> 00:01:29,000
if you add new files or remove files,
37
00:01:29,000 --> 00:01:31,000
simply refreshing the query,
38
00:01:31,000 --> 00:01:34,000
refreshing that connection will automatically append
39
00:01:34,000 --> 00:01:36,000
any new data that's shown up within the folder.
40
00:01:36,000 --> 00:01:38,000
So it's a really powerful option
41
00:01:38,000 --> 00:01:41,000
that we'll dive into within the next video.
42
00:01:41,000 --> 00:01:44,000
But for now, let's cover the basic append options
43
00:01:44,000 --> 00:01:47,000
and we'll shift gears into Power bi so we can take a look.
44
00:01:49,000 --> 00:01:51,000
Alright, so we're inside the Query Editor
45
00:01:51,000 --> 00:01:54,000
and I'm in my Sales Data 2022 table.
46
00:01:54,000 --> 00:01:57,000
And we've got a bunch of data sources in here.
47
00:01:57,000 --> 00:02:00,000
But the problem here is that none of these data sources
48
00:02:00,000 --> 00:02:04,000
share the exact same structure or data type.
49
00:02:04,000 --> 00:02:06,000
So what we need to do is we actually need to go
50
00:02:06,000 --> 00:02:08,000
and get some new data.
51
00:02:08,000 --> 00:02:09,000
Again, we're gonna do this
52
00:02:10,000 --> 00:02:13,000
right from our New Source tools,
53
00:02:13,000 --> 00:02:15,000
and we're gonna go and we're actually gonna bring in
54
00:02:15,000 --> 00:02:17,000
our other two sales data sets.
55
00:02:17,000 --> 00:02:19,000
So let's connect to 2021.
56
00:02:21,000 --> 00:02:23,000
All right, preview looks good.
57
00:02:24,000 --> 00:02:27,000
All right, I'm gonna quickly update my table name again,
58
00:02:29,000 --> 00:02:31,000
and then our column headers,
59
00:02:32,000 --> 00:02:35,000
data types, everything looks good here.
60
00:02:35,000 --> 00:02:39,000
All right, let's go back. We'll get our 2020 data set.
61
00:02:42,000 --> 00:02:45,000
And we'll add this into the query editor.
62
00:02:45,000 --> 00:02:49,000
And following our very similar repeatable process,
63
00:02:49,000 --> 00:02:51,000
we've got our data preview.
64
00:02:51,000 --> 00:02:53,000
Again, everything looks good here.
65
00:02:55,000 --> 00:02:56,000
Same steps.
66
00:02:56,000 --> 00:02:58,000
We'll update our table name
67
00:02:59,000 --> 00:03:03,000
and then I'll just confirm again that our data types,
68
00:03:03,000 --> 00:03:05,000
column headers, everything looks good.
69
00:03:06,000 --> 00:03:08,000
All right, so now we've got
70
00:03:08,000 --> 00:03:11,000
these three separate sales data files, right?
71
00:03:11,000 --> 00:03:14,000
For 2020, 2021, and 2022.
72
00:03:14,000 --> 00:03:17,000
And they are all consistent in terms
73
00:03:17,000 --> 00:03:18,000
of the number of columns,
74
00:03:18,000 --> 00:03:22,000
except for our 2022 data set, right?
75
00:03:22,000 --> 00:03:25,000
This is where we had added in our quantity type column
76
00:03:25,000 --> 00:03:29,000
when we were practicing our conditional column tools.
77
00:03:29,000 --> 00:03:30,000
So one option would be to go ahead
78
00:03:30,000 --> 00:03:33,000
and continue to append these together.
79
00:03:33,000 --> 00:03:34,000
You'll see some null values
80
00:03:34,000 --> 00:03:36,000
for the quantity types in the other two tables.
81
00:03:36,000 --> 00:03:39,000
And you could pretty easily redefine the conditional column
82
00:03:39,000 --> 00:03:41,000
to the full append version.
83
00:03:41,000 --> 00:03:44,000
In this case, we're just gonna go ahead and remove it.
84
00:03:46,000 --> 00:03:48,000
So we come over to this column,
85
00:03:48,000 --> 00:03:51,000
we can actually delete our last applied steps.
86
00:03:53,000 --> 00:03:56,000
And now we're back to the same exact structure
87
00:03:56,000 --> 00:03:58,000
across all three of these tables.
88
00:03:58,000 --> 00:04:00,000
So with one of them selected,
89
00:04:00,000 --> 00:04:01,000
it doesn't really matter which one,
90
00:04:01,000 --> 00:04:04,000
I've got 2022 selected here,
91
00:04:04,000 --> 00:04:08,000
from the Home tab, we're gonna go to the Append Queries.
92
00:04:08,000 --> 00:04:09,000
Again, right below merge.
93
00:04:09,000 --> 00:04:11,000
And again, we've got those same options
94
00:04:11,000 --> 00:04:13,000
that we saw in the Merge Queries.
95
00:04:13,000 --> 00:04:16,000
We can append queries or append queries as new.
96
00:04:16,000 --> 00:04:19,000
And for this example, I wanna append queries as new.
97
00:04:19,000 --> 00:04:22,000
I wanna create a new table that's based
98
00:04:22,000 --> 00:04:25,000
on these other three queries.
99
00:04:25,000 --> 00:04:27,000
All right, so we've got our dialogue that pops up
100
00:04:27,000 --> 00:04:29,000
and we actually have two or more tables,
101
00:04:29,000 --> 00:04:31,000
so we're gonna collect three or more tables.
102
00:04:31,000 --> 00:04:34,000
You can see here that we already are showing
103
00:04:34,000 --> 00:04:36,000
our sales data 2022 as part of the append,
104
00:04:36,000 --> 00:04:38,000
'cause that's what's selected,
105
00:04:38,000 --> 00:04:41,000
and then we have all of our other available tables here.
106
00:04:41,000 --> 00:04:45,000
And if we scroll down, we can hold down Shift
107
00:04:45,000 --> 00:04:50,000
and click 2021 and 2020, and then click Add,
108
00:04:50,000 --> 00:04:52,000
and now we've got all three of these tables
109
00:04:52,000 --> 00:04:54,000
that we are gonna append together.
110
00:04:55,000 --> 00:04:57,000
Click OK.
111
00:04:57,000 --> 00:05:00,000
So here we go, we've created this new table.
112
00:05:00,000 --> 00:05:03,000
Its name is just Appended1 by default,
113
00:05:03,000 --> 00:05:05,000
so let's update that to something
114
00:05:05,000 --> 00:05:06,000
a little bit more readable.
115
00:05:07,000 --> 00:05:12,000
So we'll call this Sales Data 2020 through 2022.
116
00:05:16,000 --> 00:05:17,000
Again, just to be clear.
117
00:05:17,000 --> 00:05:20,000
And now we can look through the column structure here.
118
00:05:20,000 --> 00:05:23,000
We can see that our columns are exactly the same.
119
00:05:23,000 --> 00:05:27,000
We select our order date drop-down and view more.
120
00:05:27,000 --> 00:05:30,000
We've got all of our 2020.
121
00:05:30,000 --> 00:05:32,000
Scroll all the way down here.
122
00:05:32,000 --> 00:05:35,000
You can see all the way down to June 30th, 2022.
123
00:05:35,000 --> 00:05:37,000
All right, and then probably in the middle here,
124
00:05:37,000 --> 00:05:39,000
we've got all of our 2021 data.
125
00:05:39,000 --> 00:05:41,000
So everything looks good there.
126
00:05:41,000 --> 00:05:44,000
We've successfully appended all of our sales data together.
127
00:05:44,000 --> 00:05:46,000
So everything might seem great,
128
00:05:46,000 --> 00:05:49,000
but one downside to this approach
129
00:05:49,000 --> 00:05:52,000
is now that I've got this table with all of the data in it,
130
00:05:52,000 --> 00:05:55,000
let's say I wanna get rid of these individual tables here,
131
00:05:55,000 --> 00:05:58,000
if I right-click and select Delete,
132
00:05:58,000 --> 00:06:01,000
I get a message from the query editor saying like,
133
00:06:01,000 --> 00:06:03,000
"Hey, we can't delete this table,
134
00:06:03,000 --> 00:06:06,000
because it's being referenced by another query."
135
00:06:06,000 --> 00:06:09,000
And Power BI won't let me actually delete this
136
00:06:09,000 --> 00:06:12,000
because it needs this table in order to populate
137
00:06:12,000 --> 00:06:14,000
this table that's appended.
138
00:06:14,000 --> 00:06:18,000
So the problem here is that our new table,
139
00:06:18,000 --> 00:06:21,000
our Sales Data 2020 through 2022,
140
00:06:21,000 --> 00:06:24,000
is dependent on three other tables.
141
00:06:24,000 --> 00:06:26,000
So we kinda have to keep all four of 'em here,
142
00:06:26,000 --> 00:06:30,000
which it's okay, but honestly it's not the greatest.
143
00:06:30,000 --> 00:06:33,000
We've got duplicate redundant queries in the editor,
144
00:06:33,000 --> 00:06:35,000
and while it's probably not really
145
00:06:35,000 --> 00:06:36,000
gonna create any big problems,
146
00:06:36,000 --> 00:06:39,000
it's just messy and not great form.
147
00:06:39,000 --> 00:06:42,000
So one way around that, which I recommend very much,
148
00:06:42,000 --> 00:06:45,000
is to move these files into a folder
149
00:06:45,000 --> 00:06:47,000
and then connect to the folder itself.
150
00:06:47,000 --> 00:06:49,000
So stay tuned, because in the next video,
151
00:06:49,000 --> 00:06:52,000
I'm gonna walk you through exactly how to do that.
11993
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.