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:03,000
Instructor: Up next, we have our number specific tools.
2
00:00:03,000 --> 00:00:06,000
So let's get back to that transform tab in the query editor.
3
00:00:06,000 --> 00:00:10,000
And assuming we have a numerical column selected,
4
00:00:10,000 --> 00:00:14,000
you'll see a group of number specific tools that are active
5
00:00:14,000 --> 00:00:15,000
that'll look something like this.
6
00:00:15,000 --> 00:00:18,000
And the first option within those number tools
7
00:00:18,000 --> 00:00:20,000
are the statistics functions.
8
00:00:20,000 --> 00:00:22,000
And these are aggregators
9
00:00:22,000 --> 00:00:27,000
like some, min, max, median, average, standard deviation,
10
00:00:27,000 --> 00:00:29,000
count, and count distinct.
11
00:00:29,000 --> 00:00:31,000
Now, you may be wondering,
12
00:00:31,000 --> 00:00:33,000
if you have a whole column selected
13
00:00:33,000 --> 00:00:35,000
and you apply an aggregation function
14
00:00:35,000 --> 00:00:38,000
that's designed to return a single value,
15
00:00:38,000 --> 00:00:38,000
how does that work?
16
00:00:38,000 --> 00:00:40,000
What happens?
17
00:00:40,000 --> 00:00:41,000
And I'll show you exactly how this works
18
00:00:41,000 --> 00:00:45,000
as soon as we jump into Power BI, but the answer is that
19
00:00:45,000 --> 00:00:48,000
these all return one value, meaning a single value.
20
00:00:48,000 --> 00:00:51,000
So the entire table gets replaced
21
00:00:51,000 --> 00:00:53,000
with that one single value.
22
00:00:53,000 --> 00:00:54,000
And as a result,
23
00:00:54,000 --> 00:00:56,000
you don't really use these statistics functions
24
00:00:56,000 --> 00:01:00,000
within the query editor as a means of transforming
25
00:01:00,000 --> 00:01:04,000
or preparing a table, but rather as a way to explore it
26
00:01:04,000 --> 00:01:06,000
and maybe get some information about it.
27
00:01:06,000 --> 00:01:09,000
So things like the count of products,
28
00:01:09,000 --> 00:01:13,000
the maximum costs, the medium age, questions like that.
29
00:01:13,000 --> 00:01:16,000
Now at this point, you also might be thinking,
30
00:01:16,000 --> 00:01:20,000
hey, can't we use the column profile tools for this?
31
00:01:20,000 --> 00:01:23,000
And the answer is, absolutely.
32
00:01:23,000 --> 00:01:24,000
The column statistics
33
00:01:24,000 --> 00:01:27,000
and the column profile view are the exact same
34
00:01:27,000 --> 00:01:30,000
as what will derive using these statistics functions.
35
00:01:30,000 --> 00:01:33,000
And this lecture is really all about exploring the tools
36
00:01:33,000 --> 00:01:35,000
and options that are available to you
37
00:01:35,000 --> 00:01:36,000
within the query editor.
38
00:01:36,000 --> 00:01:38,000
Plus, you'll never know when these statistics tools
39
00:01:38,000 --> 00:01:40,000
may come in handy.
40
00:01:41,000 --> 00:01:43,000
Now the next set of tools within this group,
41
00:01:43,000 --> 00:01:46,000
the standard scientific and trigonometry tools,
42
00:01:46,000 --> 00:01:49,000
these actually allow you to apply road level operations.
43
00:01:49,000 --> 00:01:52,000
So you can apply the same standard operation like
44
00:01:52,000 --> 00:01:55,000
addition, multiplication, division
45
00:01:55,000 --> 00:01:57,000
or some more advanced calculations like log,
46
00:01:57,000 --> 00:01:59,000
sign, tangent, et cetera.
47
00:01:59,000 --> 00:02:00,000
And these are actually applied
48
00:02:00,000 --> 00:02:03,000
to each value within the column.
49
00:02:03,000 --> 00:02:07,000
So unlike the statistics options, these tools are applied
50
00:02:07,000 --> 00:02:10,000
to each individual row within the table.
51
00:02:10,000 --> 00:02:13,000
In addition to those standard scientific and trig functions,
52
00:02:13,000 --> 00:02:16,000
you also have info functions.
53
00:02:16,000 --> 00:02:20,000
And these basically allow you to identify binary flags,
54
00:02:20,000 --> 00:02:23,000
either true or false or one or zero,
55
00:02:23,000 --> 00:02:25,000
to mark each row in a column,
56
00:02:25,000 --> 00:02:27,000
whether it's odd, even, positive or negative.
57
00:02:28,000 --> 00:02:31,000
So with that, let's open up Power BI and we'll practice
58
00:02:31,000 --> 00:02:34,000
some of these number tools.
59
00:02:34,000 --> 00:02:36,000
All right, so similar to the tech specific tools lecture,
60
00:02:36,000 --> 00:02:39,000
we're not gonna connect to new data for this lecture,
61
00:02:39,000 --> 00:02:41,000
but instead use the product lookup table.
62
00:02:41,000 --> 00:02:44,000
So we're gonna head back into the query editor,
63
00:02:44,000 --> 00:02:46,000
through that transform button,
64
00:02:46,000 --> 00:02:49,000
and we're gonna practice the numerical tools here.
65
00:02:49,000 --> 00:02:52,000
Once we're in the query editor, let's make sure we've got
66
00:02:52,000 --> 00:02:54,000
the product lookup table selected.
67
00:02:54,000 --> 00:02:58,000
And if we jump up to the add column menu,
68
00:02:58,000 --> 00:03:01,000
here are my number specific tools.
69
00:03:01,000 --> 00:03:04,000
And you'll notice that the statistics options
70
00:03:04,000 --> 00:03:06,000
are grayed out, right?
71
00:03:06,000 --> 00:03:07,000
Because they're aggregators,
72
00:03:07,000 --> 00:03:09,000
they're gonna return a single value.
73
00:03:09,000 --> 00:03:12,000
So it doesn't really make sense to add a new column
74
00:03:12,000 --> 00:03:16,000
that's derived by one of these stats functions.
75
00:03:16,000 --> 00:03:18,000
But when we move to the transform tab,
76
00:03:18,000 --> 00:03:20,000
you can see that we do have these options
77
00:03:20,000 --> 00:03:22,000
available to us, right?
78
00:03:22,000 --> 00:03:25,000
And these statistics options are active here.
79
00:03:25,000 --> 00:03:27,000
And you'll see all of these different aggregation functions
80
00:03:27,000 --> 00:03:32,000
like sum, min, max, median, average, and so on.
81
00:03:32,000 --> 00:03:35,000
Let's say for example, we wanted to understand
82
00:03:35,000 --> 00:03:39,000
the number of unique products captured in this lookup table.
83
00:03:39,000 --> 00:03:42,000
So if we click on product name
84
00:03:42,000 --> 00:03:44,000
and then head up to our statistics options,
85
00:03:44,000 --> 00:03:47,000
wait, we actually see here that a lot of these options
86
00:03:47,000 --> 00:03:49,000
are grayed out, right?
87
00:03:49,000 --> 00:03:50,000
And that kind of makes sense
88
00:03:50,000 --> 00:03:54,000
because we're asking about a text-based column, right?
89
00:03:54,000 --> 00:03:56,000
And not a numeric column.
90
00:03:56,000 --> 00:03:59,000
So you can't aggregate or sum texts
91
00:03:59,000 --> 00:04:01,000
or find the minimum or maximum values
92
00:04:01,000 --> 00:04:03,000
of a text value here, right?
93
00:04:03,000 --> 00:04:06,000
All we can do is count or count distinct.
94
00:04:06,000 --> 00:04:10,000
And in fact, all of my other number column tools
95
00:04:10,000 --> 00:04:12,000
are actually grayed out here as well.
96
00:04:12,000 --> 00:04:14,000
So let's head back here to statistics
97
00:04:14,000 --> 00:04:17,000
and we're gonna count the distinct values here
98
00:04:17,000 --> 00:04:20,000
of product name within the table.
99
00:04:20,000 --> 00:04:23,000
And we have 293.
100
00:04:23,000 --> 00:04:26,000
So what this tells me is that there are 293
101
00:04:26,000 --> 00:04:29,000
unique product names in my product lookup table.
102
00:04:29,000 --> 00:04:32,000
And like I had mentioned, as you can see it's pretty obvious
103
00:04:32,000 --> 00:04:35,000
that this isn't a means of transforming or preparing data
104
00:04:35,000 --> 00:04:37,000
to then load it into Power BI,
105
00:04:37,000 --> 00:04:41,000
it's really better suited for exploratory analysis.
106
00:04:41,000 --> 00:04:44,000
So almost every time you use these stats functions,
107
00:04:44,000 --> 00:04:45,000
what you're gonna want to do
108
00:04:45,000 --> 00:04:48,000
is delete this last applied step that's created
109
00:04:48,000 --> 00:04:50,000
to return that full table.
110
00:04:50,000 --> 00:04:54,000
All right, so let's look at another couple quick examples.
111
00:04:54,000 --> 00:04:56,000
I'm gonna scroll all the way over to the right
112
00:04:56,000 --> 00:04:59,000
and check out our product price column.
113
00:04:59,000 --> 00:05:00,000
And now in this case,
114
00:05:00,000 --> 00:05:03,000
I'm curious like, what's our average product price
115
00:05:03,000 --> 00:05:05,000
in the Adventure Works data set?
116
00:05:05,000 --> 00:05:07,000
All right, so I can click on product price here,
117
00:05:07,000 --> 00:05:10,000
we'll go back to transform, and I can come back
118
00:05:10,000 --> 00:05:13,000
to my statistics tools and click on average, right?
119
00:05:13,000 --> 00:05:17,000
And we see here we get $714 and 43 cents
120
00:05:17,000 --> 00:05:19,000
and then a big remainder here.
121
00:05:19,000 --> 00:05:21,000
This is kind of alarming, right?
122
00:05:21,000 --> 00:05:22,000
It feels pretty high.
123
00:05:22,000 --> 00:05:25,000
So if we close back out,
124
00:05:25,000 --> 00:05:29,000
you can actually see here for our product names, right?
125
00:05:29,000 --> 00:05:31,000
We've got these different road frames
126
00:05:31,000 --> 00:05:33,000
you know, medium, large, all this stuff,
127
00:05:33,000 --> 00:05:36,000
so remember this is a bike company,
128
00:05:36,000 --> 00:05:40,000
and so we probably sell a lot of higher end bike equipment.
129
00:05:40,000 --> 00:05:42,000
And you can see here in the product price column,
130
00:05:42,000 --> 00:05:47,000
you've got some values here around 12, $13,000.
131
00:05:47,000 --> 00:05:49,000
Keep scrolling, we go up a little bit higher
132
00:05:49,000 --> 00:05:51,000
to, you know, 3,500.
133
00:05:51,000 --> 00:05:53,000
So now I'm curious,
134
00:05:53,000 --> 00:05:55,000
can we use another statistics function
135
00:05:55,000 --> 00:05:58,000
to answer this question a little bit more precisely, right?
136
00:05:58,000 --> 00:06:03,000
What is our highest priced item within the dataset here?
137
00:06:03,000 --> 00:06:06,000
So what we can do is, again, we'll go back
138
00:06:06,000 --> 00:06:10,000
to this product price column, transform, statistics,
139
00:06:10,000 --> 00:06:13,000
and let's find the maximum value, right?
140
00:06:13,000 --> 00:06:15,000
And it's exactly what we just saw there.
141
00:06:15,000 --> 00:06:18,000
So a little over $3,500 here,
142
00:06:18,000 --> 00:06:21,000
pretty expensive item here within the dataset,
143
00:06:21,000 --> 00:06:26,000
and then we can click back on our X to clear this out.
144
00:06:26,000 --> 00:06:28,000
All right, so it's pretty easy to use these tools
145
00:06:28,000 --> 00:06:31,000
to explore some of the columns within your dataset.
146
00:06:31,000 --> 00:06:34,000
So let's test out a couple more of these tools here.
147
00:06:34,000 --> 00:06:36,000
And we're gonna scroll back over
148
00:06:36,000 --> 00:06:39,000
to the product price and cost columns here.
149
00:06:39,000 --> 00:06:43,000
And because we've already updated these data types
150
00:06:43,000 --> 00:06:47,000
to a fixed decimal number, let's do a little test here.
151
00:06:47,000 --> 00:06:50,000
Let's say we had left this as a decimal number, right?
152
00:06:50,000 --> 00:06:53,000
We hadn't updated this change to currency step here.
153
00:06:53,000 --> 00:06:56,000
All right, one of the things that we can do here
154
00:06:56,000 --> 00:06:58,000
is we can use
155
00:06:59,000 --> 00:07:01,000
the rounding tools from the transform menu
156
00:07:01,000 --> 00:07:03,000
and we can either round up, down,
157
00:07:03,000 --> 00:07:07,000
or we can specify the number of digits to round to
158
00:07:07,000 --> 00:07:09,000
using that third option.
159
00:07:09,000 --> 00:07:10,000
So let's say we wanna round this
160
00:07:10,000 --> 00:07:12,000
to two decimal places, right?
161
00:07:12,000 --> 00:07:14,000
And we generate this round off function.
162
00:07:16,000 --> 00:07:18,000
And you can see here that we've rounded these off
163
00:07:18,000 --> 00:07:20,000
to two significant decimal places,
164
00:07:20,000 --> 00:07:23,000
but maybe that doesn't make sense for our use case,
165
00:07:23,000 --> 00:07:27,000
maybe we want to keep the data type set to currency.
166
00:07:27,000 --> 00:07:29,000
So let's delete that last applied step.
167
00:07:29,000 --> 00:07:32,000
We'll delete the change type step there as well.
168
00:07:32,000 --> 00:07:36,000
And now we're back here to our currency data type.
169
00:07:36,000 --> 00:07:38,000
One of the last things that I want to show you here
170
00:07:38,000 --> 00:07:42,000
is I want to do a demonstration of the standard operations.
171
00:07:42,000 --> 00:07:46,000
So what I would like to do is not transform the column,
172
00:07:46,000 --> 00:07:49,000
but we're gonna keep product price selected
173
00:07:49,000 --> 00:07:51,000
and we want to add a new column
174
00:07:51,000 --> 00:07:54,000
that's based off of product price, right?
175
00:07:54,000 --> 00:07:55,000
And we're gonna do that
176
00:07:55,000 --> 00:07:57,000
using one of these standard operators.
177
00:07:57,000 --> 00:08:00,000
And what we're gonna do in this example
178
00:08:00,000 --> 00:08:03,000
is we're gonna multiply our product price
179
00:08:03,000 --> 00:08:06,000
by 0.09, all right?
180
00:08:06,000 --> 00:08:11,000
I basically want to return 90% of the product price column
181
00:08:11,000 --> 00:08:14,000
for each row within the table, right?
182
00:08:14,000 --> 00:08:16,000
So we're gonna multiply this by 0.09.
183
00:08:16,000 --> 00:08:19,000
And the way that you can think about this is,
184
00:08:19,000 --> 00:08:23,000
let's say Adventure Works as a company ran a 10% off deal.
185
00:08:23,000 --> 00:08:25,000
You know, this might be something like that
186
00:08:25,000 --> 00:08:27,000
discounted product price column.
187
00:08:27,000 --> 00:08:29,000
So we'll lock that in.
188
00:08:29,000 --> 00:08:31,000
All right, so I can see here
189
00:08:31,000 --> 00:08:33,000
that we have created the new column,
190
00:08:33,000 --> 00:08:36,000
a new applied step here for inserted multiplication.
191
00:08:36,000 --> 00:08:40,000
And we've got this, you know, pretty poor column name here.
192
00:08:40,000 --> 00:08:44,000
So let's update this to discount price.
193
00:08:46,000 --> 00:08:49,000
And the other cool thing to notice here is that because
194
00:08:49,000 --> 00:08:52,000
this column is based off of the product price column,
195
00:08:52,000 --> 00:08:54,000
it inherits the data type,
196
00:08:54,000 --> 00:08:58,000
and when we multiply the product price by 0.9
197
00:08:58,000 --> 00:09:02,000
our discounted price also is set as a currency
198
00:09:02,000 --> 00:09:05,000
or a fixed decimal number data type.
199
00:09:05,000 --> 00:09:07,000
All right, so I think that's just about everything
200
00:09:07,000 --> 00:09:09,000
that we need to do as far as modifications
201
00:09:09,000 --> 00:09:11,000
to the product lookup table.
202
00:09:11,000 --> 00:09:14,000
So let's head back to our home tab
203
00:09:14,000 --> 00:09:17,000
and we're gonna click close and apply.
204
00:09:17,000 --> 00:09:18,000
And again, like we've seen,
205
00:09:18,000 --> 00:09:21,000
this is basically just updating these queries
206
00:09:21,000 --> 00:09:23,000
and it'll apply these transformations,
207
00:09:23,000 --> 00:09:26,000
as you can see by what's happening on the screen.
208
00:09:26,000 --> 00:09:27,000
And it's great.
209
00:09:27,000 --> 00:09:30,000
It basically loads those tables, refreshes our data model.
210
00:09:30,000 --> 00:09:32,000
So if I zoom in here
211
00:09:32,000 --> 00:09:35,000
and I look at our product lookup table,
212
00:09:35,000 --> 00:09:37,000
you can see at the top here,
213
00:09:37,000 --> 00:09:39,000
we have our new discount price column
214
00:09:39,000 --> 00:09:41,000
that we had created, right?
215
00:09:41,000 --> 00:09:43,000
So that has been added into our data model.
216
00:09:44,000 --> 00:09:45,000
All right, so there you have it.
217
00:09:45,000 --> 00:09:49,000
That's your crash course in query editing number tools.
17428
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.