Download presentation
Presentation is loading. Please wait.
Published byLucy Snow Modified over 9 years ago
1
Many-To-Many in DAX Alberto Ferrari Senior Consultant SQLBI DBI413
2
Alberto Ferrari alberto.ferrari@sqlbi.com www.sqlbi.com @FerrariAlberto
6
Classical M2M We will start looking at the final result Then, we dive into the DAX code Demo – Classical M2M
9
Filter on Dim_CustomerFilter on Dim_Account
10
This filter is applied by the Tabular data model
11
FILTER: For each row in Dim_Account CALCULATE: filters the bridge
12
This filter is applied by the Tabular data model FILTER: For each row in Dim_Account CALCULATE: filters the bridge Only rows in Dim_Account where COUNTROWS () > 0 survive the FILTER
13
This filter is applied by the Tabular data model FILTER: For each row in Dim_Account CALCULATE: filters the bridge Only rows in Dim_Account where COUNTROWS () > 0 survive the FILTER SUM is evaluated only for the accounts filtered from the customers
14
AmountM2M_Correct := CALCULATE ( SUM (Fact_Transaction[Amount]), FILTER ( Dim_Account, CALCULATE ( COUNTROWS (Bridge_AccountCustomer) ) > 0 ) )
15
All the rows in the Account table survived the FILTER
16
Two rows in the Account table survived the FILTER
17
AmountM2M_Correct := CALCULATE ( SUM (Fact_Transaction[Amount]), FILTER ( Dim_Account, CALCULATE ( COUNTROWS (Bridge_AccountCustomer) ) > 0 ) )
19
The context is moved in a single Vertipaq operation
23
Cascading M2M Many-to-many with more than one bridge table Cascading many-to-many
24
Filter on Dim_CategoryFilter on Dim_Account The pattern is the same, but this time we need to jump two steps to complete our task
25
CALCULATE( SUM( Fact_Transaction[Amount] ), CALCULATETABLE ( SUMMARIZE ( BridgeAccountCustomer, DimAccount[ID_Account] ), SUMMARIZE ( Bridge_CustomerCategory, DimCustomer[ID_Customer] ) ) )
27
Need for some ETL here The bridge now «feels» three different filters, but the formula becomes a classical many to many and runs faster
29
Survey A first example of the usage of the many-to-many pattern Using M2M on Surveys
32
Question1 = «Job» Answer1 = «Consultant» Question2 = «Yearly Income»
35
Additional conditions to set the relationships with two tables in DAX only
37
Basket Analysis A pretty complex scenario, solved with the many-to-many pattern Basket Analysis Demo
40
This is the fact table… Do you really like to self-join it?
41
We can filter «Mountain Tire Tube» with this table but… where do we filter «Mountain Bike»?
42
2° filter: «Mountain Bike» 1° filter: «Mountain Tire Tube»
43
1° filter: «Mountain Bike» 2° filter: «Mountain Tire Tube» HavingProduct = Bought Both NotHavingProduct = Bought Bike, No Tire
44
Inactive Relationships
47
1° M2M Pattern 2° M2M Pattern
49
Querying M2M Well… what about performance of m2m in Tabular? Let us see them! M2M Performance
51
2,700,000 176,000 140 230 1,440 9,000 4,000,000,000
53
DBI305 Developing and Managing a BI Semantic Model in Analysis Services DBI413 Many-to-Many Relationships in BISM Tabular DBI319 BISM: Multidimensional vs. Tabular DBI62-HOL Optimizing a MS SQL Server 2012 Tabular BI Semantic Model Book Signing at Book Store on Wednesday, June 13 th, 12:30pm-1:00pm
54
@sqlserver @ms_teched mva Microsoft Virtual Academy SQL Server 2012 Eval Copy Get Certified! Hands-On Labs
55
Connect. Share. Discuss. http://northamerica.msteched.com Learning Microsoft Certification & Training Resources www.microsoft.com/learning TechNet Resources for IT Professionals http://microsoft.com/technet Resources for Developers http://microsoft.com/msdn
56
Required Slide Complete an evaluation on CommNet and enter to win!
57
Scan the Tag to evaluate this session now on myTechEd Mobile Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.