Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services.

Similar presentations


Presentation on theme: "Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services."— Presentation transcript:

1 Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services Microsoft Corporation 5-304 Global Breakout Session Hardware Provider

2

3 Yes, We Are Brothers.

4 Agenda  What is MDX?  MDX Basics  MDX Queries  Solving Business Problems with MDX

5 Functionality Knowledge Required Required Knowing MDX

6 What Is MDX  MDX = Multi Dimensional Expressions  A syntax for modeling and querying an OLAP database  Part of the OLE DB for OLAP Spec  Supported by multiple providers (OLAP Services, TM1, SAS, WhiteLight, SAP…)  It is the key for all advanced analytical capabilities of OLAP Services

7 MDX Basics  MDX allows easy navigation in the multi dimensional space  It “understands” the MD concepts of cube, dimension, level, member and cell  It is used for Queries – full statements (SELECT…FROM) Queries – full statements (SELECT…FROM) Business modeling – defining calculated members Business modeling – defining calculated members

8 MDX Constructs  Member : Nelson, [1996].[Q1].[Jan] Nelson, [1996].[Q1].[Jan]  Tuple : (Nelson, USA), (Computers, [1996]) (Nelson, USA), (Computers, [1996])  Sets : {Nelson, White} {Nelson, White} { (Computers, USA), (Printers, Japan) } { (Computers, USA), (Printers, Japan) } [1996].Children [1996].Children TopCount(SalesReps.Members, 10, Sales) TopCount(SalesReps.Members, 10, Sales)

9 MDX Queries  SELECT sets on axes (N axes)  FROM a source cube  WHERE the data is sliced by some coordinates

10 Sample Cube  Dimensions: Measures: Sales, Cost, Units Measures: Sales, Cost, Units Time: Year, Quarter, Month Time: Year, Quarter, Month Geography: All, Region, Country Geography: All, Region, Country Products: All, Product Group, Product Name Products: All, Product Group, Product Name Customers: All, Customer Group, Customer Name Customers: All, Customer Group, Customer Name

11 Select Time.year.members on Rows, Measures.members on Columns, Product.[Product Department].members on Pages From Sales Sample MDX

12 Stage 1: Creating Axes Stage 2: Getting Cells’ Values GroceriesClothing Appliances SalesCostUnits 97 98 99 9695 15135 17 13 6 22 11 7 29 9 9 30 10 8 Query Execution

13 97 98 99 Groceries Clothing Appliances SalesCostUnits (Products.Clothing, Measures.Units,Time. 98) (Products.Clothing, Measures.Sales,Time. 97) (Products.Groceries, Measures.Cost,Time.Year. 95) 96 95 Every Cell Has A Name...

14 98 Clothing Units ? ? (Products.Clothing, Measures.Units,Time. 98.PrevMember) (Products.Clothing, Measures.Units,Time. 98.NextMember) Every Cell Still Has A Name...

15 98 Clothing Units ? (Products.Clothing, Measures.Units,Time. 98.PrevMember) ? (Products.Clothing, Measures.Units,Time. 98.NextMember) ? (Products.Clothing, Measures.Units.PrevMember,Time. 98.Lag(3)) (Products.Clothing, Measures.Units.PrevMember,Time. 98.Lead(-3)) OR Every Cell Still Has A Name...

16 Calculated Members  Calculated members are the real power behind OLAP  They provide the mean to define complex business logic  MDX is the syntax for calculated members Statements – tools, query generators, developers Statements – tools, query generators, developers Calculated members – DBAs and power users Calculated members – DBAs and power users

17 97 98 99 Groceries Clothing Appliances SalesCostUnits 96 95 With member Measures.Growth as ‘(Time.currentmember,Measures.Sales)- (Time.currentmember.prevmember,Measures.Sales)’ Select Time.year.members on Rows, AddCalculatedMembers(Measures.members) on Columns, Product.[Product Department].members on Pages From Sales 15135 17 13 6 22 11 7 29 9 9 30 10 8 GrowthTime.95Empty 15 Time.CurrentMember Time.CurrentMember.PrevMember Sales Growth

18 97 98 99 Groceries Clothing Appliances SalesCostUnits 96 95 With member Measures.Growth as ‘(Time.currentmember,Measures.Sales)- (Time.currentmember.prevmember,Measures.Sales)’ Select Time.year.members on Rows, AddCalculatedMembers(Measures.members) on Columns, Product.[Product Department].members on Pages From Sales Growth Time.96 Time.95 15 2 Time.CurrentMember Time.CurrentMember.PrevMember 15 13 5 17 13 6 22 11 7 29 9 9 30 10 8 Sales Growth

19 97 98 99 Groceries Clothing Appliances SalesCostUnits 96 95 With member Measures.Growth as ‘(Time.currentmember,Measures.Sales)- (Time.currentmember.prevmember,Measures.Sales)’ Select Time.year.members on Rows, AddCalculatedMembers(Measures.members) on Columns, Product.[Product Department].members on Pages From Sales Growth Time.CurrentMember Time.CurrentMember.PrevMember Time.97 Time.96 15 2 5 13 5 17 13 6 22 11 7 29 9 9 30 10 8 Sales Growth

20 97 98 99 Groceries Clothing Appliances SalesCostUnits 96 95 With member Measures.Growth as ‘(Time.currentmember,Measures.Sales)- (Time.currentmember.prevmember,Measures.Sales)’ Select Time.year.members on Rows, AddCalculatedMembers(Measures.members) on Columns, Product.[Product Department].members on Pages From Sales Growth Time.98 Time.97 15 2 5 7 Time.CurrentMember Time.CurrentMember.PrevMember 15 13 5 17 13 6 22 11 7 29 9 9 30 10 8 Sales Growth

21 97 98 99 Groceries Clothing Appliances SalesCostUnits 96 95 With member Measures.Growth as ‘(Time.currentmember,Measures.Sales)- (Time.currentmember.prevmember,Measures.Sales)’ Select Time.year.members on Rows, AddCalculatedMembers(Measures.members) on Columns, Product.[Product Department].members on Pages From Sales Growth Time.99 Time.98 15 2 5 7 1 Time.CurrentMember Time.CurrentMember.PrevMember 15 13 5 17 13 6 22 11 7 29 9 9 30 10 8 Sales Growth

22 GetCellValue(CurrentCell) Push CurrentCell CurrentCell  Measure = Sales L = GetCellValue(CurrentCell) PopPush CurrentCell CurrentCell  Measure = Sales CurrentCell  Time = CurrentCell  Time  Prevmember R = GetCellValue(CurrentCell) Pop CurrentCell Result = L - R (Growth, 98, Clothing) GetCellValue(CurrentCell) Member  Formula? No: Return Cell Member  Calculate(CurrentCell) (Growth, 98, Clothing) (Sales, 98, Clothing) (Growth, 98, Clothing) (Sales, 98, Clothing) (Sales, 97, Clothing) (Growth, 98, Clothing) R = Sales in 97 of Clothing L = Sales in 98 of Clothing = Growth in 98 of Clothing (Sales, 98, Clothing) (Sales, 97, Clothing) Growth : ( Sales,Time.CurrentMember) – (Sales,Time.CurrentMember.PrevMember) L=29 R=22 L-R=29-22=7

23 How did sales in this period compare with sales in the previous period? How did sales in the current period compare with the same period in the previous year? What is my total since the beginning of the year? “It’s Just A Question Of Time ….”

24 10 100 10 20 5 -20 45 -15 -45 5 10 80 15 How Did Sales In This Period Compare With Sales In The Previous Period?

25 -20 45 80 15 Time.CurrentMember, Measures.CurrentMember Time.CurrentMember,Measures.Sales Time.CurrentMember.PrevMember, Measures.Sales How Did Sales In This Period Compare With Sales In The Previous Period?

26 20 10 50 -10 Sales How Did Sales In The Current Period Compare With The Same Period In The Previous Year?

27 20 (Measures,Sales,Time.CurrentMember)- (Measures.Sales,ParallelPeriod(Year,1,Time.CurrentMember)) Sales How Did Sales In The Current Period Compare With The Same Period In the Previous Year?

28 What Is My Total Since The Beginning Of The Year?

29 Sum(YTD(Time.CurrentMember),Sales) Time.Mar,Measures.Sales Time.Feb,Measures.Sales Time.Jan,Measures.Sales + + (Time.CurrentMember,Measures.Sales) + (Measures.YTD,Time.CurrentMember.Prevmember) YTD What Is My Total Since The Beginning Of The Year?

30 Navigating In The Hierarchy (The Family Tree)

31 Time.[97].parentTime.[98].parent Parents

32 Time.[97].FirstChild Children

33 Time.[97].Children Children

34 Descendants(Time.[97], Quarter) Descendants

35 Descendants(Time.[97], Month) Descendants

36 Descendants(Time.[Q1], Month) Descendants

37 Descendants(Time.[Jan], Month) Descendants

38 The Inventory Problem  A set of inventory snapshots over time Dimensions: Dimensions: Products: All Products, Family, Category, Name Warehouses: All, Warehouse Time: Year, Quarter, Month Measures: Measures: Quantity (SUM) Value (SUM)  The problem: measures are not additive over time

39 Problem: Inventory is not an additive value.. Inventory …….

40 The Business Problems…  Average quantities and stock values in each time period  Opening and closing balances for each time period  Minimum and maximum inventory levels in a time period  The relative contribution of the stocked item to the overall stock value

41 Avg( Descendants([Time].CurrentMember,[Month]), Quantity) Sum of quantities over all months in the period divided by The number of months in the period Sum ( months in the period, Quantity) / Count( months in the period ) Sum (Descendants([Time].CurrentMember,[Month]), Quantity) / Count(Descendants([Time].CurrentMember,[Month])) Average Over Time

42 Avg Inv : A vg(Descendants( [Time].CurrentMember, [Months]), Quantity) Average Over Time Push CurrentCell D = Descendents( CurrentCell  Time, Months) For Each t in D Apply(t, CurrentCell) CurrentCell  Measure = Quantity S = S + GetCellValue(CurrentCell) PopPush CurrentCell Next C = D  Count Result = S / C ([Avg Inv], Q398, WH1) GetCellValue(CurrentCell) Member  Formula? No: Return Cell Member  Calculate(CurrentCell) ([Avg Inv], Q398, WH1) ([Avg Inv], Jul98, WH1) (Quantity, Jul98, WH1) ([Avg Inv], 98, WH1) S = S + Jul98 Quantity in WH1 D = Months in Q398 = Sum of monthly inv./#months (Quantity, Jul98,WH1) = 55 (Quantity, Aug98, WH1) = 60 D = {Jul98, Aug 98, Sep98} S=55 Result = S/C = 185/3 =61.66 (Quantity, Sep98, WH1) = 70 S = S + Aug98 Quantity in WH1 S=115 S = S + Sep98 Quantity in WH1 S=185 C= Number of Q398 months C = 3 ([Avg Inv], Aug98, WH1) (Quantity, Aug98, WH1) ([Avg Inv], Sep98, WH1) (Quantity, Sep98, WH1) ([Avg Inv], 98, WH1)

43 Closing Balance Quantity of the last month in the period Quantity of the last month in the months contained in the period Quantity of the last item in (Descendants([Time].CurrentMember, [Month]) (Measures.Quantity, Tail(Descendants([Time].CurrentMember, [Month]),1)) (Measures.Quantity, ClosingPeriod([Month]))

44 50 90 70 105 (Inventory,ClosingPeriod(Month)) Closing Period Inventory Value…

45 Maximum Inventory Level In ATime Span Measures.[Maximum Inventory Value]: Max(Descendants( Time.CurrentMember,Time.Month), Measures.[Value])

46 Relative Contribution Measures.[Value Contribution to Total]: Measures.[Value] / (Measures.[Value], Products.[All], Warehouse.[All Warehouse])

47 Ranking Rank each product by sales among the other products In its category Rank( current product, other products on its category ordered by sales ) Rank(Products.CurrentMember, Order( other products on its category, Sales) Rank(Products.CurrentMember, Order( Products.CurrentMember.Parent.Children, Sales))

48


Download ppt "Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services."

Similar presentations


Ads by Google