Download presentation
Presentation is loading. Please wait.
Published byPaulina Stone Modified over 9 years ago
1
Introduction to Solving Business Problems with MDX Robert Zare and Tom Conlon Program Managers Microsoft
2
Agenda MDX basics MDX basics Time series analysis Time series analysis Multidimensional Navigation Multidimensional Navigation Snapshot data analysis Snapshot data analysis
3
What is MDX? MDX is Multi Dimensional EXpressions MDX is Multi Dimensional EXpressions MDX is the syntax for querying an Analysis Services database MDX is the syntax for querying an Analysis Services database MDX is part of the OLE DB for OLAP spec MDX is part of the OLE DB for OLAP spec MDX is the key for to utilizing the advanced analytical capabilities of Analysis Services MDX is the key for to utilizing the advanced analytical capabilities of Analysis Services
4
Comparison to SQL SQL Construct OLAP construct SELECT… SELECT… (MDX) FROM FROM…(MDX) WHERE WHERE…(MDX) CREATE… DSO object model DROP… INSERT… DELETE…
5
MDX basics MDX allows easy navigation in the multi dimensional space MDX allows easy navigation in the multi dimensional space It “understands” the MD concepts of cube, dimension, level, member and cell It “understands” the MD concepts of cube, dimension, level, member and cell It is used for It is used for – Queries – full statements (SELECT…FROM) – Business modeling – defining calculated members using MDX Expressions – not a full statement
6
MDX Queries vs. MDX Expressions MDX Queries MDX Queries – Full statements (SELECT…FROM) – Most often generated by end-user query tools and applications such as Excel or Data Analyzer – MDX Sample App deals in queries MDX Expressions MDX Expressions – Partial MDX statements – Define an analytical object such as calculated member, or named set – Return a single value (which may be a set)
7
MDX myth Fact: MDX is used everywhere: Calculated members Calculated members Security settings Security settings Custom member formula Custom member formula Custom level formula Custom level formula Actions Actions Named Sets Named Sets Calculated Cells Calculated Cells “Only developers need to know MDX”
8
MDX constructs Members: an item in a hierarchy Members: an item in a hierarchy – [John Doe] – [2001] – [2001].[Q1].[Jan] Tuple: an intersection of 2 or more members Tuple: an intersection of 2 or more members – ([Product].[Drink].[Beverages], [Customers].[USA]) – ([Product].[Non-Consumable], [2001]) Sets: a group of tuples or members Sets: a group of tuples or members – {[John Doe], [Jane Doe]} – { ( [Non-Consumable], USA ), ( Beverages, Mexico ) } – [2001].Children – TopCount(Store.[Store Name].Members, 10, Sales)
9
Groceries Clothing Appliances Sales Cost Units Every cell has a name... 1999 2000 2001 1998 1997 Measures Time Products
10
Groceries Clothing Appliances Sales Cost Units (Products.Clothing, Measures.Units, Time.[2000]) Every cell has a name... 1999 2000 2001 1998 1997 Measures Time Products
11
Groceries Clothing Appliances Sales Cost Units (Products.Clothing, Measures.Units, Time.[2000]) (Products.Clothing, Measures.Sales, Time.[1999]) Every cell has a name... 1999 2000 2001 1998 1997 Measures Time Products
12
Groceries Clothing Appliances Sales Cost Units (Products.Clothing, Measures.Units, Time.[2000]) (Products.Clothing, Measures.Sales, Time.[1999]) (Products.Groceries, Measures.Cost, Time.Year.[1997]) Every cell has a name... 1999 2000 2001 1998 1997 Measures Time Products
13
1999 2000 2001 Groceries Clothing Appliances SalesCostUnits (Products.Clothing, Measures.Units, Time.[2000]) = (Products.CurrentMember, Measures.CurrentMember, Time.CurrentMember) 1998 1997 The current cell: CurrentMember
14
2000 Clothing Sales ? Naming cells with relative references...
15
2000 Clothing Sales ? ? (Products.Clothing, Measures.Sales, Time.[2000].PrevMember)
16
2000 Clothing Sales ? ? ? Naming cells with relative references... (Products.Clothing, Measures.Sales, Time.[2000].PrevMember) (Products.Clothing, Measures.Sales, Time.[2000].NextMember)
17
(Products.Clothing, Measures.Sales.PrevMember, Time.[2000].Lag(3)) 2000 Clothing Sales ? ? ? Naming cells with relative references... (Products.Clothing, Measures.Sales, Time.[2000].PrevMember) (Products.Clothing, Measures.Sales, Time.[2000].NextMember) OR(Products.Clothing,Measures.Sales.PrevMember, Time.[2000].Lead(-3))
18
Calculated members Calculated members add significant power to cubes Calculated members add significant power to cubes Pre-define complex business logic (so that user does not have to) Pre-define complex business logic (so that user does not have to) Computed at run- time Computed at run- time
19
Agenda MDX basics MDX basics Time series analysis Time series analysis Multidimensional Navigation Multidimensional Navigation Snapshot data analysis Snapshot data analysis
20
1. How did Sales this period compare with Sales in the previous period? YearQtrMonSales 2000790 Q1120 Jan30 Feb40 Mar50 Q2200 Apr65 May45 Jun90 Q3185 Jul55 Aug60 Sep70 Q4285 Oct80 Nov100 Dec105
21
QtrMonSalesDelta Q220080 Apr6515 May45-20 Jun9045 (Time.CurrentMember, Measures.CurrentMember) =
22
QtrMonSalesDelta Q220080 Apr6515 May45-20 Jun9045 1. How did Sales this period compare with Sales in the previous period? (Time.CurrentMember, Measures.CurrentMember) = (Time.CurrentMember, Measures.Sales) -
23
QtrMonSalesDelta Q220080 Apr6515 May45-20 Jun9045 (Time.CurrentMember.PrevMember, Measures.Sales) 1. How did Sales this period compare with Sales in the previous period? (Time.CurrentMember, Measures.CurrentMember) = (Time.CurrentMember, Measures.Sales) -
24
Calculated measure: [Sales Growth]
25
2. How did Sales in the current period compare with Sales in the same period last year? YearQtrMonSales 2000790 Q1120 Jan30 Feb40 Mar50 Q4285 Oct80 Nov100 Dec105 2001850 Q1 Q1170 Jan50 Feb55 Mar65 Q4275 Oct90 Nov100 Dec85
26
YearQtrMonSales Annual Delta 2000790 Q1120 Jan30 Feb40 Mar50 2001850 Q1 Q1170 Jan5020 Feb55 Mar65 2. How did Sales in the current period compare with Sales in the same period last year? (Time.CurrentMember, Measures.Sales)- (Time.CurrentMember.Lag(12), Measures.Sales)
27
YearQtrMonSales Annual Delta 2000790 Q1120 Jan30 Feb40 Mar50 2001850 Q1 Q1170 Jan5020 Feb55 Mar65 2. How did Sales in the current period compare with Sales in the same period last year? (ParallelPeriod(Year,1,Time.CurrentMember), Measures.Sales) (Time.CurrentMember.Lag(12), Measures.Sales) (Time.CurrentMember, Measures.Sales)-
28
Calculated measure: [Sales Growth Y/Y]
29
3. What have my sales been since the beginning of the year? YearQtrMonSales 2000790 Q1120 Jan30 Feb40 Mar50 Q2200 Apr65 May45 Jun90 Q3185 Jul55 Aug60 Sep70 Q4285 Oct80 Nov100 Dec105
30
Time.Mar,Measures.Sales... Time.Jan,Measures.Sales + Time.Feb,Measures.Sales+ 3. What have Sales been since the beginning of the year? YearQtrMonSalesYTD 2000790 Q1120120 Jan3030 Feb4070 Mar50120
31
Time.Mar,Measures.Sales Time.Jan,Measures.Sales + Time.Feb,Measures.Sales+ = Sum(YTD(Time.CurrentMember), Sales) YearQtrMonSalesYTD2000790 Q1120120 Jan3030 Feb4070 Mar50120
32
Calculated measure: [YTD Sales]
33
Agenda MDX basics MDX basics Time series analysis Time series analysis Multidimensional Navigation Multidimensional Navigation Snapshot data analysis Snapshot data analysis
34
Navigating the hierarchy (The Family Tree)
35
Parents
36
Time.[2000].Parent Parents
37
Time.[2000].Parent Time.[2001].Parent Parents
38
Time.[2000].FirstChild Children
39
Time.[2000].FirstChild Children
40
Time.[2000].Children Children
41
Descendants( Time.[2000], Quarter) Descendants
42
Descendants( Time.[2000], Month) Descendants
43
Descendants(Time.[2000].[Jan], Month) Descendants
44
Descendants
45
Agenda MDX basics MDX basics Time series analysis Time series analysis Multidimensional Navigation Multidimensional Navigation Snapshot data analysis Snapshot data analysis
46
The Inventory Problem A set of inventory snapshots over time A set of inventory snapshots over time – Dimensions Products: (All), Family, Category, Name Products: (All), Family, Category, Name Warehouses: (All), Warehouse Warehouses: (All), Warehouse Time: Year, Quarter, Month Time: Year, Quarter, Month Store: (All), Country, City, Store Store: (All), Country, City, Store – Measures Quantity [default aggregation=sum] Quantity [default aggregation=sum] – The problem: Measures are not additive over time Measures are not additive over time
47
The inventory problem: Semi-additive measures YearQtrMonthQuantity2000790 Q1120 Jan30 Feb40 Mar50 Q2200 Apr65 May45 Jun90 Q3185 Jul55 Aug60 Sep70 Q4285 Oct80 Nov100 Dec105 Problem: Quantity is not additive over time
48
Business solutions… 1.Average quantities in each time period 2.Opening and closing balances for each time period 3.Minimum and maximum inventory levels in a time period
49
1. Average over time 1.Sum of quantities over all months in the period, divided by the number of months in the period 2.Sum( months in the period, Quantity) / Count( months in the period ) 3.Sum(Descendants( Time.CurrentMember,[Month]), Quantity) / Count(Descendants( Time.CurrentMember,[Month])) 4.Avg( Descendants( Time.CurrentMember,[Month]), Quantity)
50
Calculated measure: [Average balance]
51
2. Closing period inventory value… YearQtrMonthQtyCalc2000790105 Q112050 Jan3030 Feb4040 Mar5050 Q220090 Apr6565 May4545 Jun9090 Q318570 Jul5555 Aug6060 Sep7070 Q4285105 Oct8080 Nov100100 Dec105105
52
2. Closing balance 1.Quantity of the last month in the period 2.Quantity of the last item in (Descendants(Time.CurrentMember, [Month]) 3.(Tail( Descendants( Time.CurrentMember, [Month]), 1), Measures.Quantity) 4.(ClosingPeriod([Month], Time.CurrentMember), Measures.Quantity)
53
Calculated measure: [Closing Balance]
54
3. Maximum Quantity During the Period We want the Maximum monthly inventory value for each period We want the Maximum monthly inventory value for each period Max( Descendants( Time.CurrentMember, Month), Measures.Quantity ) Max( Descendants( Time.CurrentMember, Month), Measures.Quantity ) – Why did we calculate using Descendants(…, Month)? Why not use the Children function?
55
Calculated measure: [Maximum Quantity]
56
Summary MDX is everywhere MDX is everywhere Calculated members are the most common application of MDX in cube modeling Calculated members are the most common application of MDX in cube modeling Understand the fundamental concepts: CurrentMember,.Parent,.Children, Descendants, etc. as these are the building blocks for many expressions Understand the fundamental concepts: CurrentMember,.Parent,.Children, Descendants, etc. as these are the building blocks for many expressions
57
More Information Books Books – Step by Step Analysis Services Jacobsen Jacobsen – Microsoft OLAP Solutions Thomsen, Spofford, Chase Thomsen, Spofford, Chase – MDX Solutions Spofford Spofford Online Online – Public Newsgroup Microsoft.public.sqlserver.olap Microsoft.public.sqlserver.olap – MSN Community http://groups.msn.com/MicrosoftOLAPServicesUsersCommunity /_homepage.msnw?pgmarket=en-us http://groups.msn.com/MicrosoftOLAPServicesUsersCommunity /_homepage.msnw?pgmarket=en-us – Microsoft.com http://microsoft.com/sql/evaluation/bi/default.asp http://microsoft.com/sql/evaluation/bi/default.asp
58
Don’t forget to complete the on-line Session Feedback form on the Attendee Web site https://web.mseventseurope.com/teched/ https://web.mseventseurope.com/teched/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.