Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,660 --> 00:00:06,160
It's time to shake things up a little bit to this point we've been dealing with a pretty simple straightforward
2
00:00:06,160 --> 00:00:12,730
model just our one data table sales data table and a bunch of individual lookups that we've created
3
00:00:12,730 --> 00:00:15,460
connections or relationships to.
4
00:00:15,490 --> 00:00:16,380
Now here's the thing.
5
00:00:16,390 --> 00:00:22,120
I just got off the phone with our client and Adventure Works and it turns out they have another data
6
00:00:22,120 --> 00:00:29,110
table with information about product returns that they'd like us to integrate into the model as well.
7
00:00:29,110 --> 00:00:34,360
So in other words they don't just need us to analyze product sales but they want to get a sense of which
8
00:00:34,360 --> 00:00:37,510
products are being returned most often as well.
9
00:00:37,510 --> 00:00:40,930
So what we're dealing with here is something like this.
10
00:00:41,200 --> 00:00:45,280
In this particular case we've got a simplified model with three lookup tables.
11
00:00:45,280 --> 00:00:52,270
Customer look up calendar and product look up and two data tables sales data and returns data each with
12
00:00:52,270 --> 00:00:55,400
its own set of dates and other foreign keys.
13
00:00:55,780 --> 00:00:59,260
But take a minute and look at the relationships here.
14
00:00:59,260 --> 00:01:05,380
What you'll notice is that the sales data is connected with one to many relationships to all three of
15
00:01:05,380 --> 00:01:05,980
the lookups.
16
00:01:05,980 --> 00:01:08,750
Customer look up calendar and product look up.
17
00:01:09,100 --> 00:01:14,600
But the thing is the return's data is only connected to the calendar and the product Look-Up.
18
00:01:14,830 --> 00:01:20,950
We don't have any way to connect return's data to customer look up since we don't have a foreign customer
19
00:01:20,950 --> 00:01:28,720
key and this isn't entirely uncommon especially for larger or more complex real world models where you're
20
00:01:28,720 --> 00:01:31,370
pulling in data from a number of different sources.
21
00:01:31,570 --> 00:01:37,960
It's actually quite uncommon to have the exact same set of foreign keys in every source data table that
22
00:01:37,960 --> 00:01:39,280
you're working with.
23
00:01:39,280 --> 00:01:45,130
So this is the type of scenario that you may very well run into in a real world application.
24
00:01:45,130 --> 00:01:52,090
So what this means is that we can analyze sales and returns data sales quantities and returns quantities
25
00:01:52,570 --> 00:02:00,280
within the same view or visual and power be-I but only if we filter or segment our data using fields
26
00:02:00,280 --> 00:02:02,390
from shared lookup tables.
27
00:02:02,410 --> 00:02:07,900
So looking at the returns data in this particular case we know which product was returned because we
28
00:02:07,900 --> 00:02:13,630
have a product key and we know which date the product was returned because we have a return date.
29
00:02:13,810 --> 00:02:18,040
But we know nothing about the customer who made the return.
30
00:02:18,130 --> 00:02:24,560
So there's no way we could slice or dice or filter that returns data by any field in the customer looked
31
00:02:25,030 --> 00:02:30,060
like names marital status gender income or any of those fields.
32
00:02:30,070 --> 00:02:37,030
So what you may be noticing here is that we've successfully integrated that returns data into the model.
33
00:02:37,120 --> 00:02:43,640
But we did not attempt to make any kind of relationship between the returns data and the sales data.
34
00:02:43,780 --> 00:02:49,630
And the reason for that is that no matter which fields we tried to use to form a relationship between
35
00:02:49,630 --> 00:02:55,670
those two data tables we're always going to run into a many to many relationship error.
36
00:02:55,930 --> 00:03:01,740
And that's because both data tables sales and returns have multiple dates and the date fields.
37
00:03:02,020 --> 00:03:08,050
They have multiple products and the Product Key field multiple territories in the Territory field and
38
00:03:08,050 --> 00:03:09,010
so on so forth.
39
00:03:09,010 --> 00:03:14,530
So even if we wanted to connect those two together there would be no way because we have no field that
40
00:03:14,530 --> 00:03:17,350
would give us a valid one to many relationship.
41
00:03:17,350 --> 00:03:19,760
So that's a very very important point.
42
00:03:20,080 --> 00:03:25,870
Generally speaking you will never create direct relationships between data tables.
43
00:03:25,870 --> 00:03:30,980
Instead you connect them indirectly through shared lookup tables.
44
00:03:31,300 --> 00:03:37,660
So what we're going to do now is jump back into power be-I we actually have that returns the file that
45
00:03:37,660 --> 00:03:42,340
we're going to load up and then we're going to wire into our model creating relationships just like
46
00:03:42,340 --> 00:03:43,400
the ones you see here.
47
00:03:44,450 --> 00:03:49,640
All right so once you're back in the relationships view beard venture works report go ahead to the Home
48
00:03:49,640 --> 00:03:51,100
tab and click get data.
49
00:03:51,290 --> 00:03:53,920
We're going to get our last filed the projects.
50
00:03:53,970 --> 00:03:57,800
It's another CXXVI and this time we want adventure works.
51
00:03:57,800 --> 00:03:59,460
Underscore returns.
52
00:03:59,660 --> 00:04:02,590
So go ahead and double click.
53
00:04:02,800 --> 00:04:04,270
Take a look at the preview.
54
00:04:04,540 --> 00:04:06,360
Pretty simple dataset here.
55
00:04:06,420 --> 00:04:07,570
Got a return date.
56
00:04:07,620 --> 00:04:13,120
The territory key product key and that numerical quantity field as well.
57
00:04:13,390 --> 00:04:22,150
So let's edit this file to fire up the query editor and first things first said to our table name call
58
00:04:22,150 --> 00:04:22,560
this one.
59
00:04:22,570 --> 00:04:24,780
A.W. returns.
60
00:04:24,790 --> 00:04:26,200
Check our headers.
61
00:04:26,220 --> 00:04:26,920
They're promoted.
62
00:04:26,920 --> 00:04:29,110
We've got dates for a return date.
63
00:04:29,110 --> 00:04:32,840
Whole numbers for territory key product key and quantity.
64
00:04:32,860 --> 00:04:34,060
Very straightforward.
65
00:04:34,090 --> 00:04:35,290
All looks good.
66
00:04:35,290 --> 00:04:42,180
Let's go ahead and just close and apply just like it is and we'll see that object pop in right here
67
00:04:42,180 --> 00:04:43,340
in our relationship view
68
00:04:46,150 --> 00:04:47,000
where we go.
69
00:04:47,180 --> 00:04:50,780
So here's our second data table.
70
00:04:51,200 --> 00:04:53,540
Click and drag and make some room for it here.
71
00:04:54,680 --> 00:05:00,740
And I want to make it clear that these two tables here are the two data tables that we care about.
72
00:05:00,990 --> 00:05:08,280
Now remember I can't just grab a field a foreign key from my returns table and try to force a connection
73
00:05:08,280 --> 00:05:14,580
right to my sales table because I'll get that many to many relationship error can't create a relationship
74
00:05:14,820 --> 00:05:22,050
because one of them must have uniques press OK and the same holds even if I try to use my keys territory
75
00:05:22,050 --> 00:05:24,720
kid territory he can't do that either.
76
00:05:24,720 --> 00:05:31,320
So again the way that we integrate a second data table or a third or fourth or fifth for that matter
77
00:05:31,470 --> 00:05:37,000
is by wiring it and creating the same relationships just like we would with any other table.
78
00:05:37,140 --> 00:05:45,780
So territory key can connect to territory key return date can connect to calendar date and then last
79
00:05:45,780 --> 00:05:53,070
but not least Product Key can connect to product key and by association product subcategory and category
80
00:05:53,100 --> 00:05:54,210
as well.
81
00:05:54,210 --> 00:06:00,810
So again no customer key means that we can't form a relationship with that customer lookup table.
82
00:06:01,020 --> 00:06:07,380
Now to really hammer that point home and understand how this impacts our analysis let's jump all the
83
00:06:07,380 --> 00:06:09,160
way back up to the report view.
84
00:06:09,360 --> 00:06:14,580
And as you can see we've still got our matrix here showing product name and order quantity.
85
00:06:14,580 --> 00:06:20,450
So what I'm going to do is select that Matrix could see my returns table is populated here I'm going
86
00:06:20,450 --> 00:06:27,780
to grab a return quantity and pull it in right under order quantity in my values and it can expand to
87
00:06:27,780 --> 00:06:30,290
view and take a look.
88
00:06:30,290 --> 00:06:31,850
This looks great.
89
00:06:31,880 --> 00:06:38,120
I'm now seeing order quantities and return quantities side by side in the same visual broken down by
90
00:06:38,120 --> 00:06:39,450
product name.
91
00:06:39,680 --> 00:06:41,590
So that's really helpful.
92
00:06:41,600 --> 00:06:47,480
And I can get a lot of insight from this but what if we want to see the same view the same values broken
93
00:06:47,480 --> 00:06:48,750
down by gender instead.
94
00:06:48,770 --> 00:06:53,390
I'm curious if men or women tend to return items more frequently.
95
00:06:53,390 --> 00:06:59,360
So instead of product name let's pull that right out of our matrix and let's go ahead and drill into
96
00:06:59,360 --> 00:07:07,820
our customer look at and right here we can find gender pull that into rows and take a look at this.
97
00:07:07,970 --> 00:07:13,850
We see the order quantity which seems to be correct but for return quantity get that same repeating
98
00:07:13,940 --> 00:07:20,330
number issue that we've seen in the past and almost every time you see that repeating number issue it's
99
00:07:20,330 --> 00:07:22,640
because of a relationship problem.
100
00:07:22,640 --> 00:07:28,670
And in this case the relationship problem is that we're trying to apply a filter from the customer table
101
00:07:29,150 --> 00:07:36,200
and show values from returns which is an unrelated disconnected table and that goes back to the point
102
00:07:36,200 --> 00:07:37,510
that I made earlier.
103
00:07:37,730 --> 00:07:44,180
You can only view fields from both of these data tables in the same visual when you're filtering or
104
00:07:44,180 --> 00:07:51,380
segmenting using a field from a common or shared look up since the customer table is not shared by both
105
00:07:51,380 --> 00:07:52,090
of these.
106
00:07:52,100 --> 00:07:57,010
This is an invalid view and that's why we see these duplicate erroneous values.
107
00:07:57,350 --> 00:07:59,550
So let's jump back to our relationships to you.
108
00:08:00,810 --> 00:08:03,550
And this is our finalized data model.
109
00:08:03,570 --> 00:08:05,640
So we've got all of our tables in here.
110
00:08:05,670 --> 00:08:08,130
We've got all of our relationships in place.
111
00:08:08,130 --> 00:08:12,310
This is going to set us up for some really interesting analyses down the line.
112
00:08:12,420 --> 00:08:18,660
But before we move on to calculated fields with daks and then visualisations we need to hit one more
113
00:08:18,660 --> 00:08:23,850
really important concept when it comes to data modeling which is the filter flow.
114
00:08:23,850 --> 00:08:24,690
So stay tuned.
115
00:08:24,690 --> 00:08:25,900
That's coming up next.
12052
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.