Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,570 --> 00:00:00,840
All right.
2
00:00:00,840 --> 00:00:03,120
Time to kick off our Dax demos.
3
00:00:03,120 --> 00:00:08,700
Now we're going to start by focusing on calculated columns first since that a bit more user friendly
4
00:00:08,760 --> 00:00:09,900
a bit more intuitive.
5
00:00:10,110 --> 00:00:13,770
And we're gonna kick it off with basic date and time functions.
6
00:00:13,800 --> 00:00:15,860
So here's what we're gonna be dealing with.
7
00:00:16,170 --> 00:00:19,570
Now all you sell users this should look really really familiar.
8
00:00:19,650 --> 00:00:25,190
These basic date time functions are very user friendly really simple syntax.
9
00:00:25,260 --> 00:00:28,980
So this should be a breeze starting with day month year.
10
00:00:28,980 --> 00:00:34,410
I call these component functions because they essentially point to a date and extract some specific
11
00:00:34,410 --> 00:00:38,460
component of that date day the month or the year.
12
00:00:38,460 --> 00:00:41,450
So syntax wise incredibly straightforward.
13
00:00:41,460 --> 00:00:45,450
You just point it to a column containing your dates and you're good to go.
14
00:00:45,450 --> 00:00:47,910
Same thing holds with our minutes second.
15
00:00:47,940 --> 00:00:54,030
The only real difference is that you have to point to a column with a date time component as well because
16
00:00:54,030 --> 00:01:00,720
what these hour minute second functions do is they ignore the date and only focus on the hour the minute
17
00:01:01,020 --> 00:01:04,290
or the second of the timestamp component.
18
00:01:04,350 --> 00:01:11,190
Now today and now those are volatile functions which means that they update or refresh every time there's
19
00:01:11,190 --> 00:01:17,980
a workbook change and those two functions return the current date or the current exact time respectively.
20
00:01:18,300 --> 00:01:21,560
Syntax wise literally could not be simpler.
21
00:01:21,570 --> 00:01:27,210
This function doesn't even take a single argument you literally open and close the parentheses and you're
22
00:01:27,210 --> 00:01:28,480
all set.
23
00:01:28,560 --> 00:01:34,770
Now week day and week number two of my favorite date functions here weekday returns a weekday number
24
00:01:35,040 --> 00:01:42,060
by default from 1 to 7 representing Sunday to Saturday and week num captures the week number of the
25
00:01:42,060 --> 00:01:43,020
year.
26
00:01:43,020 --> 00:01:46,920
So for syntax first argument is the date column.
27
00:01:46,920 --> 00:01:52,710
Second argument is the return type and this is where you can tell power by exactly how you want your
28
00:01:52,710 --> 00:01:56,800
weeks to start whether it's a Saturday or Sunday or Monday etc..
29
00:01:56,910 --> 00:02:03,270
Now EO month another really helpful one believe it stands for end of month because it returns the last
30
00:02:03,270 --> 00:02:07,560
day of the month plus or minus a specified number of months.
31
00:02:07,560 --> 00:02:10,590
So here's what the syntax for EO month looks like.
32
00:02:10,590 --> 00:02:14,880
You point to a start date and then you specify that number of months.
33
00:02:14,880 --> 00:02:20,640
So if you use a zero for the second argument here the month function will essentially give you the last
34
00:02:20,640 --> 00:02:23,010
date of that current month.
35
00:02:23,010 --> 00:02:28,290
If you use a negative one it would give you the last date of the previous month and vice versa.
36
00:02:28,290 --> 00:02:34,530
Now little protip here even though it's a bit of a misnomer you can use the EO month function to return
37
00:02:34,530 --> 00:02:37,360
the beginning or the first of the month as well.
38
00:02:37,380 --> 00:02:44,340
I don't believe power by or Excel have any first of month equivalent functions but what you can do is
39
00:02:44,340 --> 00:02:49,210
set that month's argument to negative 1 and then simply add one day.
40
00:02:49,230 --> 00:02:55,320
So plus 1 at the very end of the function that basically calculates the last day of the previous month
41
00:02:55,710 --> 00:03:00,510
and adds one more day to give you the first date of the current month and then last but not least we've
42
00:03:00,510 --> 00:03:02,160
got date diff returns.
43
00:03:02,160 --> 00:03:08,190
The difference between two dates but not only that but it allows you to select a specific interval as
44
00:03:08,190 --> 00:03:16,440
well so date 1 your start date date to your end date and your interval which gets as granular as seconds
45
00:03:16,770 --> 00:03:18,620
or as broad as years.
46
00:03:18,630 --> 00:03:23,040
So a really helpful function for calculating the difference between two dates.
47
00:03:23,340 --> 00:03:28,980
With that let's open up our venture works file and start adding some new date and time columns to our
48
00:03:28,980 --> 00:03:31,110
model.
49
00:03:31,190 --> 00:03:31,550
All right.
50
00:03:31,560 --> 00:03:36,760
So once you've opened up your adventure works Report Let's navigate to the Data tab.
51
00:03:36,840 --> 00:03:42,300
This is gonna be kind of our home base for the next few videos as we create these calculated columns
52
00:03:42,300 --> 00:03:43,710
and measures to our model.
53
00:03:43,920 --> 00:03:49,020
And I'll make sure you're following along because we're gonna be creating new fields new measures that
54
00:03:49,020 --> 00:03:52,160
are going to be important for us to analyze and visualize.
55
00:03:52,230 --> 00:03:56,630
Once we get to the next section of the course we start building reports and dashboards.
56
00:03:56,850 --> 00:03:58,360
So pay close attention.
57
00:03:58,500 --> 00:04:00,780
Try to follow along step by step.
58
00:04:00,780 --> 00:04:06,620
Now the first demo that I'm going to use is the weekday function so I can right click anywhere inside
59
00:04:06,630 --> 00:04:09,240
this table really doesn't matter where.
60
00:04:09,240 --> 00:04:13,580
Select new column and I'll just tack that column right to the end of the table.
61
00:04:13,590 --> 00:04:21,820
So let's go ahead and name this day of week and we're gonna use the weekday function here.
62
00:04:21,870 --> 00:04:29,790
So as we start typing you'll see that not only does the formula or function name populate but a description
63
00:04:29,790 --> 00:04:30,900
populates as well.
64
00:04:30,900 --> 00:04:37,200
So really helpful tool tips and intelligence functionality that power RBI offers here.
65
00:04:37,440 --> 00:04:43,220
So I could tab to lock that in and it takes me right to the first argument which is the date.
66
00:04:43,290 --> 00:04:49,880
So let's go ahead and start typing to find that field type date which gives us the option there or we
67
00:04:49,880 --> 00:04:52,440
type calendar to navigate to that table.
68
00:04:52,440 --> 00:04:54,490
Either way it helps us find it.
69
00:04:54,810 --> 00:04:58,910
And then again I can tab or double click to select that field.
70
00:04:59,010 --> 00:05:06,570
And now with date fields specifically this additional list of options appears dot date dot day dot month
71
00:05:07,020 --> 00:05:09,210
and so on all the way to dot year.
72
00:05:09,510 --> 00:05:12,440
And this is power by being pretty slick.
73
00:05:12,540 --> 00:05:19,140
It's saying OK I see that you selected a date field it knows that calendar look up date is formatted
74
00:05:19,230 --> 00:05:26,820
as a date and it's giving us the option to either use the actual date itself by default or to use some
75
00:05:26,910 --> 00:05:32,310
aggregated component of the date like the month or the quarter or the year just like those day month
76
00:05:32,310 --> 00:05:34,270
year functions actually work.
77
00:05:34,330 --> 00:05:37,190
But it's kind of embedded in here which is pretty clever.
78
00:05:37,320 --> 00:05:44,010
Now I don't have to select any of these options or if I select dot date it would be redundant but basically
79
00:05:44,010 --> 00:05:48,440
the same thing in this case I want to reference the actual date itself.
80
00:05:48,750 --> 00:05:52,890
So I'm just gonna press comma and it takes me right to the next argument of the function.
81
00:05:52,890 --> 00:05:56,430
Now remember this is the optional component the return type.
82
00:05:56,430 --> 00:06:00,870
You can see that it's optional because it's shown in brackets in that tooltip.
83
00:06:01,140 --> 00:06:06,500
And my options are one two or three where one is a week starting Sunday.
84
00:06:06,510 --> 00:06:12,960
Two is a week starting Monday and three is another week starting Monday but from zero to six instead
85
00:06:12,960 --> 00:06:14,460
of 1 through 7.
86
00:06:14,460 --> 00:06:18,240
So I kind of like defining my weeks starting on Mondays.
87
00:06:18,390 --> 00:06:24,870
So let's enter the two here closed the function off with the closing parentheses and then press enter
88
00:06:24,930 --> 00:06:27,800
to lock that function in and there you go.
89
00:06:27,940 --> 00:06:34,750
See we get ones through sevens where ones are my Monday rows sevens are my Sunday rows.
90
00:06:35,010 --> 00:06:39,370
So there you have it pretty straightforward demo of the week day function.
91
00:06:39,420 --> 00:06:47,370
Next up let's actually collapse the calendar and navigate to our customer table scroll all the way to
92
00:06:47,370 --> 00:06:53,760
the right here and you'll remember we have this Berthier column which we had actually calculated within
93
00:06:53,760 --> 00:06:54,800
the query editor.
94
00:06:54,870 --> 00:07:01,010
So we don't see any kind of Dax formula here even though that was technically a calculated column.
95
00:07:01,050 --> 00:07:07,770
So what I'd like to show you is how we can create that same Berthier column using Dax and then remove
96
00:07:07,800 --> 00:07:09,240
the original.
97
00:07:09,240 --> 00:07:17,680
So again right click anywhere in the table new column I'm going gonna name this one Berthier underscore
98
00:07:18,160 --> 00:07:24,640
C.C. for calculated column just so that we can compare the two side by side and differentiate them.
99
00:07:24,640 --> 00:07:36,050
So Berthier C.C. equals the year of the customer lookup birth date column.
100
00:07:36,050 --> 00:07:45,570
So a tab to lock it in close the parentheses and press Enter now when I scroll over there it is Bertha
101
00:07:45,580 --> 00:07:48,930
or C.C. against the original Berthier.
102
00:07:49,220 --> 00:07:51,260
It all lines up which is good.
103
00:07:51,260 --> 00:07:57,800
And you may have been wondering can't we use that shortcut power by tip that automatically extracts
104
00:07:57,800 --> 00:08:00,100
the year without even writing a function.
105
00:08:00,140 --> 00:08:01,770
Well yes you're very sharp.
106
00:08:01,940 --> 00:08:03,020
You sure can.
107
00:08:03,050 --> 00:08:08,510
Let's go ahead and edit this I'll show you how to do this exact same calculation using a different type
108
00:08:08,510 --> 00:08:13,780
of approach so instead of using the year function explicitly.
109
00:08:13,780 --> 00:08:22,300
What if we just point to the birth date field and then use power b eyes tip and say Just give us the
110
00:08:22,300 --> 00:08:26,980
birthday that year or just the year component of that date field.
111
00:08:27,280 --> 00:08:33,270
Presenter scroll on over and what do you know.
112
00:08:33,270 --> 00:08:36,510
Give us the exact same correct values.
113
00:08:36,650 --> 00:08:40,080
It's technically a third way to accomplish the same thing.
114
00:08:40,170 --> 00:08:46,740
Calculating the birth year using the query editor or using both of those Dax or function approaches.
115
00:08:46,740 --> 00:08:51,660
Now want to show you one other interesting thing which is obviously we don't need to birth year here
116
00:08:51,870 --> 00:08:53,170
in this table.
117
00:08:53,310 --> 00:09:00,720
So watch what happens when I right click and delete the birth year column.
118
00:09:00,810 --> 00:09:04,140
So remember that birth year column that I just deleted.
119
00:09:04,140 --> 00:09:08,120
That column was added it was calculated in the query editor.
120
00:09:08,130 --> 00:09:13,290
So there was an applied step that added that calculated column to the table.
121
00:09:13,290 --> 00:09:19,320
So now what you might be wondering is every time we refresh this customer table isn't that Berthier
122
00:09:19,320 --> 00:09:25,230
column just going to keep appearing and appearing and appearing and the answer luckily is no.
123
00:09:25,320 --> 00:09:33,640
Because power VII is very smart and we go to edit queries and navigate to that customer table and check
124
00:09:33,640 --> 00:09:34,030
it out.
125
00:09:34,030 --> 00:09:40,180
It removed the birth year column as a new applied step so that it's not going to keep recreating that
126
00:09:40,180 --> 00:09:40,920
column.
127
00:09:40,960 --> 00:09:47,830
It knows that we just deleted it from the table itself in the Data tab and so it saved us the trouble
128
00:09:47,830 --> 00:09:50,920
of having to delete it over and over and over now.
129
00:09:50,980 --> 00:09:57,160
The last date time demo that I want to show you formula to calculate the current age of our customers
130
00:09:57,640 --> 00:10:03,560
so let's stick right here in our customer table and for this one Let's practice the date dif function.
131
00:10:03,910 --> 00:10:15,770
So it's right click new column we're gonna name this one current age equals or start with the date.
132
00:10:15,810 --> 00:10:23,110
Def to arrow down and tab that one in and I remember three arguments date 1 start date.
133
00:10:23,300 --> 00:10:26,360
DATE TO THE END DATE AND interval.
134
00:10:26,360 --> 00:10:32,470
So our starting date is the customer's birthday so there it is.
135
00:10:32,470 --> 00:10:33,470
Customer lookup.
136
00:10:33,500 --> 00:10:34,740
Birth date.
137
00:10:34,840 --> 00:10:37,300
I don't need any of these time components here.
138
00:10:37,420 --> 00:10:41,020
And then the date to the end date is going to be the current date.
139
00:10:41,250 --> 00:10:47,730
So we use the today function Open Close parentheses for that one and then comma to my last component.
140
00:10:47,740 --> 00:10:49,180
The interval.
141
00:10:49,300 --> 00:10:50,140
This says OK.
142
00:10:50,170 --> 00:10:56,050
By default I'm going to return the number of days between the two date arguments the start date and
143
00:10:56,050 --> 00:10:56,810
the end date.
144
00:10:56,860 --> 00:11:04,090
In this case we're looking for the current age in years so we can just scroll right down to year press
145
00:11:04,090 --> 00:11:14,220
tab to enter it close the parentheses and press enter and we scroll on over there you have got current
146
00:11:14,310 --> 00:11:18,800
ages seventy sixty nine sixty seven and so on and so forth.
147
00:11:18,900 --> 00:11:20,490
So great way to use the date.
148
00:11:20,490 --> 00:11:28,650
Def function in that example and now just for fun I'm curious if we change that last interval component
149
00:11:30,040 --> 00:11:35,560
I wonder how many seconds old these people are close it off changed year to second
150
00:11:38,070 --> 00:11:39,330
and there you go.
151
00:11:39,330 --> 00:11:48,060
Looks like our first customer here Blake Flores is just under two point two billion seconds old which
152
00:11:48,170 --> 00:11:53,910
is not very helpful for the purposes of our analysis and I don't think our adventure works clients are
153
00:11:53,910 --> 00:11:57,160
going to care much about that but kind of interesting to see.
154
00:11:57,180 --> 00:11:59,920
So let's go ahead and change that back to here.
155
00:12:00,060 --> 00:12:08,150
Close it off press enter and now we have a more appropriate ages there.
156
00:12:08,160 --> 00:12:12,930
So there you have it just a little sampling of some of those basic date and time functions.
157
00:12:12,930 --> 00:12:16,830
We practiced week day today and date diff.
158
00:12:16,860 --> 00:12:22,660
Next up we're going to talk about logical operators and some conditional if and and or statements.
159
00:12:22,710 --> 00:12:23,220
Stay tuned.
16955
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.