Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,880 --> 00:00:01,140
All right.
2
00:00:01,150 --> 00:00:07,470
Let's move on to date specific tools looking at the ad column menu in our query editor.
3
00:00:07,540 --> 00:00:11,140
We'll see those date and time tools grouped here on the right.
4
00:00:11,140 --> 00:00:13,500
And these are actually pretty straight forward.
5
00:00:13,570 --> 00:00:14,950
Got a few options here.
6
00:00:14,980 --> 00:00:20,830
One of the more interesting ones right at the top of the list is the age option and then actually automatically
7
00:00:20,830 --> 00:00:26,830
calculates the difference between the current time based on that today or now function and the actual
8
00:00:26,830 --> 00:00:28,780
date in each row.
9
00:00:28,780 --> 00:00:35,080
You also have the date only tool which basically looks at any fields that might contain both a date
10
00:00:35,110 --> 00:00:36,260
and a timestamp.
11
00:00:36,310 --> 00:00:40,560
And it strips the time component out and leaves you with just that date only.
12
00:00:40,690 --> 00:00:46,930
You also have your pretty basic set of date component functions like year month quarter week and day
13
00:00:47,420 --> 00:00:54,070
and that basically just extracts individual components or individual attributes from a date field.
14
00:00:54,250 --> 00:01:00,040
And if you're selecting a field that has a timestamp as well you also have similar time specific options
15
00:01:00,340 --> 00:01:06,490
like hour minute and second to other ones that I want to call out here earliest and latest you'll see
16
00:01:06,490 --> 00:01:09,590
those two at the bottom of the list and they're both great out.
17
00:01:09,670 --> 00:01:15,460
And that's because we're in the add column menu and both of those functions act just like the statistics
18
00:01:15,460 --> 00:01:22,150
tool and they return a single value so to access those two options you'll need to grab them from the
19
00:01:22,150 --> 00:01:23,640
transform option.
20
00:01:23,710 --> 00:01:28,300
And as you might have guessed the earliest option is going to return the earliest date in the column
21
00:01:28,690 --> 00:01:30,980
latest is going to return the last date.
22
00:01:31,060 --> 00:01:37,540
So quick note here you'll almost always want to perform these date operations from the ad column menu
23
00:01:37,810 --> 00:01:44,320
as opposed to transform since most of the time the goal is to actually build out new fields using these
24
00:01:44,320 --> 00:01:50,430
date components as opposed to overwriting or transforming an individual date or time column.
25
00:01:50,560 --> 00:01:58,600
So protip here you can actually do empower by quite easily is load up a table that just contains a single
26
00:01:58,660 --> 00:02:05,470
set of dates or you can create a date table and then use these date tools to actually build out an entire
27
00:02:05,770 --> 00:02:07,390
robust calendar.
28
00:02:07,420 --> 00:02:10,390
So that's exactly what I'm going to show you how to do in a second.
29
00:02:10,450 --> 00:02:13,710
But first let me give you a little peek of what that's going to look like.
30
00:02:13,780 --> 00:02:17,550
So we're going to start with a single column containing dates.
31
00:02:17,550 --> 00:02:23,650
We're going to apply those predefined date options using the add column tab in a query Ed. We're going
32
00:02:23,650 --> 00:02:29,920
to transform that individual column into an entire calendar containing additional fields like the day
33
00:02:29,920 --> 00:02:35,530
of the week the day name start of the week month quarter year et cetera.
34
00:02:35,560 --> 00:02:37,590
So let's open up power I and give this a shot.
35
00:02:38,670 --> 00:02:43,830
All right so if you're following along go ahead and open up your adventure works report file you should
36
00:02:43,830 --> 00:02:50,130
see those two tables we've got customer and product going to go ahead and get data grab a third table
37
00:02:50,160 --> 00:02:51,340
from a CSP.
38
00:02:51,840 --> 00:02:59,020
And this time we want our adventure works calendar table so you double click Preview it's very straightforward.
39
00:02:59,030 --> 00:03:01,920
Just a single column containing our dates.
40
00:03:01,920 --> 00:03:07,290
Go ahead and click edit to launch the query editor and here we are.
41
00:03:07,300 --> 00:03:08,790
So first two steps.
42
00:03:08,890 --> 00:03:14,230
Table name first let's make it consistent a W calendar.
43
00:03:14,340 --> 00:03:20,320
I could leave it here but since this is technically a look up table as well I want to be consistent.
44
00:03:20,410 --> 00:03:21,850
So I'm going to add lookup at the end.
45
00:03:21,850 --> 00:03:29,560
So a W underscore calendar underscore look up presenter obviously the data type looks good recognized
46
00:03:29,560 --> 00:03:31,630
and formatted as a date.
47
00:03:31,630 --> 00:03:34,040
And I've got a column header so check check.
48
00:03:34,060 --> 00:03:35,370
We're good to go.
49
00:03:35,480 --> 00:03:38,560
Now let's explore some of these date tools.
50
00:03:38,560 --> 00:03:44,590
And I want to actually start with the earliest and latest options so I'm going to go to the transform
51
00:03:44,590 --> 00:03:51,850
menu which again is the only place I can access these two options and when I click earliest it behaves
52
00:03:51,880 --> 00:03:58,080
just like those stats functions transforms the entire table into a single aggregated value.
53
00:03:58,120 --> 00:04:01,750
In this case it's one date January 1st 2015.
54
00:04:01,840 --> 00:04:07,510
That tells me that's the earliest date in my sample so we can close that step.
55
00:04:07,720 --> 00:04:15,860
Get back where we started and repeat the process for the latest date 630 30 2017.
56
00:04:15,900 --> 00:04:21,990
So that tells us that the scope of the data set that we're dealing with is from January 1st 2015 through
57
00:04:21,990 --> 00:04:26,780
the end of June 2017 or about two and a half years of daily data.
58
00:04:26,820 --> 00:04:29,820
So I'll X out of that applied step as well.
59
00:04:29,820 --> 00:04:36,510
Now let's shift gears into the add column tab and this time I want to create some new fields based on
60
00:04:36,510 --> 00:04:36,960
this date.
61
00:04:37,710 --> 00:04:40,870
So as you can see I've got all my options here.
62
00:04:40,890 --> 00:04:45,010
Let's start with a day option and choose name of day.
63
00:04:45,090 --> 00:04:51,210
So obviously that just created a brand new column exactly like we'd expect and it gave it a column header
64
00:04:51,210 --> 00:04:53,420
by default day name.
65
00:04:53,430 --> 00:04:56,480
Now I can customize those headers in this case I'm okay with that.
66
00:04:56,490 --> 00:04:58,350
So I'll leave it as is.
67
00:04:58,350 --> 00:05:03,270
And now it's important to note when you use these data tools that you have to have your date column
68
00:05:03,270 --> 00:05:05,800
selected to access those tools.
69
00:05:05,940 --> 00:05:11,700
I accidentally selected date name for instance which is really just a text string and I access those
70
00:05:11,700 --> 00:05:14,200
tools you'll see that now they're great out.
71
00:05:14,200 --> 00:05:20,490
You can't really do anything except pass that field since it's a text string so I'll select my date
72
00:05:20,520 --> 00:05:23,860
again and I've got access to everything.
73
00:05:23,910 --> 00:05:30,460
So another interesting one I want to show you is weak and I want to do the start of the week here and
74
00:05:30,520 --> 00:05:37,100
there you have it as you can see power RBI has decided that a week starts on Sunday.
75
00:05:37,260 --> 00:05:40,640
So January 4th 2015 was a Sunday.
76
00:05:40,810 --> 00:05:46,350
The next week starts on January 11th which was the next Sunday and so on and so forth.
77
00:05:46,450 --> 00:05:50,150
You can actually change this and it's not very intuitive.
78
00:05:50,230 --> 00:05:55,690
You actually have to dig in to the M code which I told you we weren't going to do but I lied I want
79
00:05:55,690 --> 00:05:59,080
to show you this just because it's a really helpful little tip.
80
00:05:59,080 --> 00:06:05,020
And what you're going to do is expanded the formula bar here and you see where it says Date dots start
81
00:06:05,020 --> 00:06:11,440
of week and then the word date in brackets I'm going to click my cursor right after the closing bracket
82
00:06:12,040 --> 00:06:14,190
and press a comma.
83
00:06:14,200 --> 00:06:19,930
Now there's two different ways to determine a custom start date for the week.
84
00:06:19,930 --> 00:06:25,930
Number one I could type just a number which power be I will interpret as a day of the week and I know
85
00:06:25,930 --> 00:06:28,450
for a fact that number one represents a Monday.
86
00:06:28,930 --> 00:06:34,400
So if I just type that one and press Enter now you'll see these dates all shifted by one.
87
00:06:34,420 --> 00:06:42,040
So now the start of the week is on a Monday the 5th the 12th the 19th etc. You can go back in and press
88
00:06:42,040 --> 00:06:45,310
two you'll see a shift again to a Tuesday.
89
00:06:45,310 --> 00:06:51,190
So that's the first way to update the second way which is a little bit more readable is to actually
90
00:06:51,190 --> 00:06:55,450
type de dot and then the name of the weekday.
91
00:06:55,510 --> 00:07:02,580
So day dot Monday and there you go I've got my Monday start weeks January 5th 12th etc..
92
00:07:02,770 --> 00:07:09,400
So let's go ahead and leave it just like that as is our collapse my formula bar and I remember I have
93
00:07:09,400 --> 00:07:16,690
started a week selected I'm going to go back and select date before access these tools and let's go
94
00:07:16,690 --> 00:07:19,620
ahead and grab some month yields.
95
00:07:19,690 --> 00:07:25,460
So I want the start of the month Jan 1 scroll down.
96
00:07:25,470 --> 00:07:28,050
Fab one looks good.
97
00:07:28,050 --> 00:07:33,300
Select date again let's go ahead do the month name at the bottom here.
98
00:07:33,310 --> 00:07:34,820
Name of month.
99
00:07:34,820 --> 00:07:35,930
There we go.
100
00:07:35,950 --> 00:07:37,570
And then we'll do two more for the years.
101
00:07:37,570 --> 00:07:39,640
I don't really need quarters in this case.
102
00:07:39,790 --> 00:07:44,700
So let's do the start of the year and then the last one.
103
00:07:44,700 --> 00:07:51,400
Let's do the actual year itself so year and that looks like a great start.
104
00:07:51,400 --> 00:07:57,100
I think that's pretty much all that I'll need I've got date the day name the start of the week start
105
00:07:57,100 --> 00:08:02,480
of the month name of the month start of the year and the year itself.
106
00:08:02,650 --> 00:08:10,090
And so at this calendar table will allow me to do is filter and segment the values in my data set in
107
00:08:10,090 --> 00:08:13,450
my data model by any of these fields that I've just created.
108
00:08:13,810 --> 00:08:22,000
So it will allow me to look at things like sales not only by day but by week or by month or by day of
109
00:08:22,000 --> 00:08:22,900
the week.
110
00:08:22,990 --> 00:08:29,380
And that's going to be really helpful as we start using more of these analysis and visualization tools.
111
00:08:29,380 --> 00:08:31,540
So our calendar is good to go.
112
00:08:31,660 --> 00:08:39,410
Let's click on our hometown press clothes and apply and it will load it up into our model and there
113
00:08:39,410 --> 00:08:42,130
you go we have our third table accessible here.
114
00:08:42,190 --> 00:08:48,230
Let's check the relationships view three table objects with all of those fields which is created based
115
00:08:48,230 --> 00:08:50,180
on that one single date column.
116
00:08:50,270 --> 00:08:51,070
And there you have it.
117
00:08:51,280 --> 00:08:52,550
Creating date tools.
12458
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.