Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:05,040 --> 00:00:07,260
Welcome to this section on measures.
2
00:00:07,410 --> 00:00:12,270
So we're going to be looking at how we can use measures in our calculations on Power BI.
3
00:00:12,630 --> 00:00:17,130
You're going to see that using our decks is that we can create calculations in a different method to
4
00:00:17,130 --> 00:00:19,900
what we've just been through in our calculate columns.
5
00:00:19,920 --> 00:00:24,870
However, there's often confusion as to whether I should be using a measure or should I be using a calculated
6
00:00:24,870 --> 00:00:25,530
column.
7
00:00:25,680 --> 00:00:29,430
Because quite honestly, sometimes you can use either or and you would probably still get the right
8
00:00:29,430 --> 00:00:30,100
result.
9
00:00:30,120 --> 00:00:34,650
However, sometimes you can only use a measure to actually get the correct result, or you could only
10
00:00:34,650 --> 00:00:36,080
use a calculated column.
11
00:00:36,090 --> 00:00:40,320
So the reality is, like most things in life, this is something that you're going to have to practice.
12
00:00:40,320 --> 00:00:44,280
You're going to have to get a bit of experience around and you're going to find again, I'm going to
13
00:00:44,280 --> 00:00:48,720
reference Excel that you're going to see that it's going to be like Excel in terms of knowing when to
14
00:00:48,720 --> 00:00:49,800
use which one.
15
00:00:50,430 --> 00:00:52,440
So we're going to move into our measures.
16
00:00:52,440 --> 00:00:57,520
So first off, you can see that I'm back in my data screen and I've chosen my data table.
17
00:00:57,540 --> 00:01:02,280
Now, you'll remember that I created the calculated columns for my sales cost and profit.
18
00:01:02,280 --> 00:01:09,210
And what it did was it basically created a new column and it created a row by row calculation of a result.
19
00:01:09,360 --> 00:01:12,180
Now, the first thing to note is that a measure does not do this.
20
00:01:12,180 --> 00:01:15,930
So basically a measure does not create a result within a table.
21
00:01:15,960 --> 00:01:19,380
A measure always creates a result within a visualization.
22
00:01:19,890 --> 00:01:23,340
So what we're going to do is we're going to start off by just using an example.
23
00:01:23,340 --> 00:01:26,190
And what we're going to do is we're going to take this sales field.
24
00:01:26,190 --> 00:01:29,040
And what we're going to do is we're going to then total this sales field.
25
00:01:29,040 --> 00:01:31,170
We're going to get a total sales value.
26
00:01:31,530 --> 00:01:33,360
So you can see our calculated column.
27
00:01:33,360 --> 00:01:39,900
At the moment we've got sales and basically we got 60,919 results for that sales because it's bit by
28
00:01:39,900 --> 00:01:41,010
bit calculation.
29
00:01:41,280 --> 00:01:45,460
But let's go into our new measure, so please make sure you're picking new measure.
30
00:01:45,480 --> 00:01:47,250
Please do not pick the new column.
31
00:01:47,550 --> 00:01:48,720
And we're going to start off.
32
00:01:48,720 --> 00:01:50,070
We're going to new measure.
33
00:01:50,460 --> 00:01:52,440
And again, you're going to see that it works the same way.
34
00:01:52,440 --> 00:01:55,430
We've got a formula bar just like we did with our calculator column.
35
00:01:55,440 --> 00:01:57,210
It needs a unique name.
36
00:01:57,210 --> 00:02:00,450
So we're going to say that this is going to be our total sales.
37
00:02:00,600 --> 00:02:06,990
Again, it follows the same syntax where we put the name of the field and then we say, Well, in this
38
00:02:06,990 --> 00:02:09,180
case it's actually more of a measure than a field.
39
00:02:09,180 --> 00:02:12,150
So we're going to call it total sales, I'm going to say equals.
40
00:02:12,270 --> 00:02:17,520
And what we're going to do is we're going to say that the total sales is the sum of the sales field.
41
00:02:17,610 --> 00:02:18,810
Now, you can picture this.
42
00:02:18,810 --> 00:02:27,120
If you had an Excel column and say, for example, you had a one to a 60,919, just like we've got here,
43
00:02:27,150 --> 00:02:36,960
60,919 rows, if you were to go down to the bottom row and you were to say equal sum, a one to a 60,919,
44
00:02:36,960 --> 00:02:41,940
it would then give you one cell that has the result of the entire calculation.
45
00:02:42,360 --> 00:02:43,860
That's really what we're going to be doing.
46
00:02:43,860 --> 00:02:46,200
So we're going to say in this case, we want to sum this.
47
00:02:46,200 --> 00:02:49,890
So we start typing and you can see that there is this sum function.
48
00:02:49,920 --> 00:02:53,850
You'll also see that there's some additional functions up there that if you use to excel, there's some
49
00:02:53,850 --> 00:02:56,400
new ones there that you may not be used to.
50
00:02:56,430 --> 00:02:59,160
Again, we're going to use our parentheses and we're going to open.
51
00:02:59,160 --> 00:03:03,450
And you can see now that I get a list of all my actual field names.
52
00:03:03,450 --> 00:03:07,950
But in this case, now I've also got the names of the table because I've got two tables that are in
53
00:03:07,950 --> 00:03:08,760
my dataset.
54
00:03:08,760 --> 00:03:13,230
So I'm actually going to go down and we're going to say that we want to use the data table and we're
55
00:03:13,230 --> 00:03:15,370
going to use the sales field.
56
00:03:15,390 --> 00:03:20,550
So again, you can see that the sales field is in the square brackets, whereas the table name is actually
57
00:03:20,550 --> 00:03:21,060
not.
58
00:03:21,060 --> 00:03:23,460
So the table name is just straight there data.
59
00:03:23,460 --> 00:03:26,310
And then we have sales within the square brackets.
60
00:03:26,760 --> 00:03:26,940
Okay.
61
00:03:27,060 --> 00:03:30,240
So you can see we've got total sales equals the sum of the sales.
62
00:03:30,240 --> 00:03:34,560
When I press enter, you'll now see that no new column has been created here.
63
00:03:34,560 --> 00:03:36,230
Nothing new has been created.
64
00:03:36,240 --> 00:03:42,840
However, in our data table you can see that we now have this new field called total sales.
65
00:03:43,050 --> 00:03:44,520
You'll see that it gets a different icon.
66
00:03:44,520 --> 00:03:46,500
It gets like a calculator type icon.
67
00:03:46,500 --> 00:03:49,080
So this is telling me that this is actually a measure.
68
00:03:49,260 --> 00:03:54,060
So when what does it mean when I say that the calculation is going to be done within a visualization?
69
00:03:54,210 --> 00:03:58,970
Well, what it means is that at the moment, this total sales is actually doing nothing within my data
70
00:03:58,980 --> 00:03:59,250
model.
71
00:03:59,250 --> 00:04:00,630
It's not taking any space.
72
00:04:00,630 --> 00:04:05,520
Whereas these calculated columns here are actually taking up space and resources because of the fact
73
00:04:05,520 --> 00:04:06,930
that they're producing a result.
74
00:04:07,680 --> 00:04:10,500
So let's jump across to the report and let's just see how this works.
75
00:04:10,500 --> 00:04:13,260
So we're going to use a table again just to show this.
76
00:04:13,410 --> 00:04:15,270
We've been using our subregion.
77
00:04:15,270 --> 00:04:18,089
So our subregion is basically a list of all different countries.
78
00:04:18,089 --> 00:04:19,170
Let's drop that in.
79
00:04:19,500 --> 00:04:19,890
Now.
80
00:04:19,890 --> 00:04:25,080
If I were to take my sales field, just the normal sales field that I've calculated, we know by default
81
00:04:25,080 --> 00:04:27,600
what happens here is that it actually sums this up.
82
00:04:27,600 --> 00:04:29,490
So it's summing up the sales.
83
00:04:29,880 --> 00:04:33,060
So let's take on new field, which is our total sales field.
84
00:04:33,060 --> 00:04:38,250
We drop that in and you'll see now that we get total sales and we get exactly the same result because
85
00:04:38,250 --> 00:04:40,320
obviously it's doing the same calculation.
86
00:04:40,320 --> 00:04:45,690
It's summing the sales because remember, it's equals the sum of the actual sales itself.
87
00:04:45,690 --> 00:04:47,460
We get exactly the same results.
88
00:04:47,670 --> 00:04:53,370
But one thing to note is that when we go to summer sales and you do the dropdown is you can change this
89
00:04:53,370 --> 00:04:56,130
to an average, to a minimum, to a maximum to account.
90
00:04:56,430 --> 00:05:00,570
However, if we go to the total sales, you'll see that we don't get those options.
91
00:05:00,870 --> 00:05:04,890
So when you're working with the measure and we're working with the sum, all it can do is a some we
92
00:05:04,890 --> 00:05:08,950
cannot change the method of aggregation because it's not working with the same level of detail.
93
00:05:08,970 --> 00:05:12,960
What it's actually doing is it's now summing the cells within the visualization.
94
00:05:12,960 --> 00:05:17,760
So it's looking at the data that's being brought into the visualization and is calculating according
95
00:05:17,760 --> 00:05:19,470
to the results within this.
96
00:05:19,530 --> 00:05:24,300
So in this case, it's now calculating for each of the sub region what is the sum of the sales.
97
00:05:24,390 --> 00:05:29,640
So that's the first big thing to realize about a measure is that we're always calculating with the visualization.
98
00:05:29,640 --> 00:05:34,250
However, you tend to find that measures can be much more efficient in terms of the calculations.
99
00:05:34,260 --> 00:05:38,100
They tend to do a lot less calculations and therefore be much more efficient.
100
00:05:38,100 --> 00:05:42,690
And also they're not taking up so much space in your data model because they're not being stored against
101
00:05:42,690 --> 00:05:44,640
the actual table itself.
102
00:05:45,210 --> 00:05:49,320
Also, once we've picked this, you'll see that we can format this just like any other field.
103
00:05:49,320 --> 00:05:54,870
So if I pick my total sales, you see, I'll get now measured tools, but I get the same options.
104
00:05:54,870 --> 00:05:57,030
So I say, what is the name of it?
105
00:05:57,030 --> 00:05:58,020
I could change that.
106
00:05:58,020 --> 00:06:00,180
Also, what is the home table now?
107
00:06:00,180 --> 00:06:04,170
A measure that actually needs to be unique within your data model.
108
00:06:04,170 --> 00:06:08,460
So that means that it can actually be stored against any table because it's a calculation.
109
00:06:08,640 --> 00:06:11,750
It actually doesn't have to be against a specific table.
110
00:06:11,760 --> 00:06:15,840
So in this case, we're storing against the data table because it makes more sense because my sales
111
00:06:15,840 --> 00:06:17,070
are actually in the data table.
112
00:06:17,070 --> 00:06:19,710
But you could store it against the data table if you wanted.
113
00:06:19,710 --> 00:06:24,300
You could change this and store it, and it would still work exactly the way that you've seen at the
114
00:06:24,300 --> 00:06:24,890
moment.
115
00:06:24,900 --> 00:06:29,070
So Measure does not actually have to be linked to a specific table.
116
00:06:29,070 --> 00:06:30,750
It can be linked to any table.
117
00:06:30,780 --> 00:06:35,190
However, it does have to be linked to a table, so just take that into consideration.
118
00:06:35,190 --> 00:06:40,890
And then the second part is when you're doing a calculated column is that the field name must be unique
119
00:06:40,890 --> 00:06:41,940
within the table.
120
00:06:42,180 --> 00:06:48,300
However, a measure must be unique within the data model, so you cannot have the same measure name
121
00:06:48,300 --> 00:06:49,020
twice.
122
00:06:49,170 --> 00:06:51,090
So just something to take into account.
123
00:06:51,600 --> 00:06:54,810
Now you'll see that you get the same formatting options as we see in previously.
124
00:06:54,810 --> 00:06:57,840
And also in this case, I can change this to 1000 separator.
125
00:06:58,050 --> 00:07:03,420
It goes to decimal number and then I can now say that I want zero decimal places.
126
00:07:04,250 --> 00:07:07,870
Hopefully you've sort of seen that how a measure is created.
127
00:07:07,880 --> 00:07:11,780
I've given some context as to basically some of the rules around it.
128
00:07:11,780 --> 00:07:13,100
Let's just create a couple more.
129
00:07:13,100 --> 00:07:18,590
But I want to first create let's say, for example, we've got our total profit, so we want to take
130
00:07:18,590 --> 00:07:19,280
this total profit.
131
00:07:19,280 --> 00:07:20,750
We want to add up the profit.
132
00:07:20,750 --> 00:07:25,670
But then what we want to do is we want to take the profit divided by our sales, and this gives me a
133
00:07:25,670 --> 00:07:26,720
profit ratio.
134
00:07:27,020 --> 00:07:31,040
So basically there'll be something that within a measure we can actually do because we're now going
135
00:07:31,040 --> 00:07:33,560
to tell one amount to be divided by the other.
136
00:07:33,560 --> 00:07:35,050
But let's have an example of that.
137
00:07:35,060 --> 00:07:35,360
Now.
138
00:07:35,360 --> 00:07:37,610
I can create a measure within my report.
139
00:07:37,610 --> 00:07:41,390
So we're going to go up here, We're going to say we want to create a new measure, and in this case,
140
00:07:41,390 --> 00:07:44,510
we're going to say that we want our total profit.
141
00:07:45,820 --> 00:07:47,350
I'm going to say equals on this.
142
00:07:47,350 --> 00:07:49,450
And again, we're going to be using awesome.
143
00:07:50,710 --> 00:07:56,230
And again, we're going to now go down and we're going to use our data profit field to some.
144
00:07:57,210 --> 00:08:00,720
So as you can see, we've got total profit equals the sum of our profit press.
145
00:08:00,720 --> 00:08:01,710
Enter on that.
146
00:08:02,160 --> 00:08:05,020
We've now got a new measure.
147
00:08:05,040 --> 00:08:06,600
Drop that into our table.
148
00:08:06,630 --> 00:08:07,650
We've now got total profit.
149
00:08:07,680 --> 00:08:09,260
I'm going to remove this for summer sales.
150
00:08:09,270 --> 00:08:10,360
Just take it out of there.
151
00:08:10,380 --> 00:08:12,240
Just to show you the total profit as well.
152
00:08:12,270 --> 00:08:15,630
You'll see that there's no methods of aggregation, but it gives us a totals.
153
00:08:15,660 --> 00:08:21,660
Again, if you've got the total profit selected, could go up to your formatting and just remove those
154
00:08:21,660 --> 00:08:22,380
decimals.
155
00:08:23,690 --> 00:08:24,350
So there we go.
156
00:08:24,380 --> 00:08:26,990
We've now got our total sums and not total profit.
157
00:08:27,410 --> 00:08:30,560
Now, what we might want to do, as I say, is to create a ratio.
158
00:08:30,560 --> 00:08:34,010
So we might want to say, how much is this as a percentage of this.
159
00:08:34,010 --> 00:08:37,130
So we want to now take this figure divided by this figure.
160
00:08:37,950 --> 00:08:43,169
Now what we can do is create another new measure, and we're going to call this our profit ratio.
161
00:08:45,210 --> 00:08:46,950
And we're going to say equals in this.
162
00:08:47,070 --> 00:08:52,350
And in this case, what we're going to do is we're going to use a Dak's function called divide.
163
00:08:53,250 --> 00:08:54,420
I'm going to select Divide.
164
00:08:55,500 --> 00:08:57,900
And you'll see at the top it says divide.
165
00:08:57,900 --> 00:09:00,410
What is my numerator over my denominator?
166
00:09:00,420 --> 00:09:02,670
So basically my numerator is the value on the top.
167
00:09:02,700 --> 00:09:05,010
Now, in this case, I want to take my total profit.
168
00:09:05,250 --> 00:09:10,500
And if you use your left square bracket again, what it will show you now is actually which measures
169
00:09:10,500 --> 00:09:11,570
do you have available.
170
00:09:11,580 --> 00:09:14,880
So I can actually use measures within other calculations.
171
00:09:14,880 --> 00:09:21,300
So in this case I'm going to say I want to use my total profit comma, open up again, my total sales.
172
00:09:21,810 --> 00:09:26,790
So this can actually make it really nice when you're doing your calculations to be instead of being
173
00:09:26,790 --> 00:09:32,820
able to have to use expressions, you can actually use the actual measures within your calculations.
174
00:09:33,090 --> 00:09:34,350
So let's see the result of that.
175
00:09:34,350 --> 00:09:39,070
We've got our profit ratio equals divide, our total profit over our total sales.
176
00:09:39,090 --> 00:09:44,730
Please note that you're using a comma here, not a divide sign, so just watch out for that.
177
00:09:45,210 --> 00:09:49,050
So I'm going to press enter on that and we now get our profit ratio again.
178
00:09:49,050 --> 00:09:50,130
You can see it's got that.
179
00:09:50,130 --> 00:09:54,990
Drop it in there and you can see now that it's now calculated that as a ratio.
180
00:09:55,620 --> 00:10:00,750
And again, with this, what I could do is I could set my different formatting so I could say I want
181
00:10:00,750 --> 00:10:04,590
this is a percentage and we have one decimal and there we go.
182
00:10:04,590 --> 00:10:06,510
We now go to our profit ratio.
183
00:10:07,330 --> 00:10:07,630
Okay.
184
00:10:07,630 --> 00:10:09,160
So we're going to conclude the lesson there.
185
00:10:09,190 --> 00:10:10,300
In the next activity.
186
00:10:10,300 --> 00:10:12,430
We're going to create some more of these measures.
187
00:10:12,430 --> 00:10:15,970
Just to give you some examples of what we can do, I'm going to conclude the lesson.
188
00:10:16,160 --> 00:10:16,990
See you in the next one.
18627
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.