Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module 8: Introduction to MDX Module 8 Introduction to MDX

Similar presentations


Presentation on theme: "Module 8: Introduction to MDX Module 8 Introduction to MDX"— Presentation transcript:

1 Module 8: Introduction to MDX Module 8 Introduction to MDX
Course 10778A Module 8: Introduction to MDX Module 8 Introduction to MDX

2 Module 8: Introduction to MDX
Course 10778A Module Overview Module 8: Introduction to MDX MDX Fundamentals Adding Calculations to a Cube Using MDX to Query a Cube

3 Lesson 1: MDX Fundamentals
Course 10778A Lesson 1: MDX Fundamentals Module 8: Introduction to MDX What Is MDX? Basic MDX Query Syntax Specifying Query and Slicer Axes Establishing Cube Context Inform students that this is an introduction to Multidimensional Expressions (MDX) and extensive MDX syntax is beyond the scope of this course.

4 Module 8: Introduction to MDX
Course 10778A What Is MDX? Module 8: Introduction to MDX MDX expression ([Measures].[Sales Amount] - [Measures].[Total Product Cost – Fact Reseller Sales]) / [Measures].[Sales Amount] Point out similarities to, and differences from, Structured Query Language (SQL). Also inform students that, in most cases, they can build MDX statements by using templates and by performing drag-and-drop operations to move objects into query panes. MDX statement SELECT { ([Measures].[Reseller Sales Amount], [Date].[Calendar Year].[CY 2010]), ([Measures].[Reseller Sales Amount], [Date].[Calendar Year].[CY 2011]) } ON COLUMNS FROM [Adventure Works] MDX for security

5 Module 8: Introduction to MDX
Course 10778A Basic MDX Query Syntax Module 8: Introduction to MDX [ WITH <SELECT WITH clause> [ , <SELECT WITH clause> ... ] ] SELECT [ * | ( <SELECT query axis clause> [ , <SELECT query axis clause> ... ] ) ] FROM <SELECT subcube clause> [ <SELECT slicer axis clause> ] [ <SELECT cell property list clause> ] [ WHERE Set_Expression ] Point out the use of SELECT, FROM, and WHERE clauses, bracketed object names, and qualified names on the slide. SELECT { ([Measures].[Reseller Sales Amount], [Date].[Calendar Year].[2010].[Q1]), ([Measures].[Reseller Sales Amount], [Date].[Calendar Year].[2011].[Q2]) } ON COLUMNS FROM [Adventure Works] WHERE ( [Sales Territory].[Southwest] ) SELECT, FROM, and WHERE clauses Bracketed object names, and qualified names

6 Specifying Query and Slicer Axes
Course 10778A Specifying Query and Slicer Axes Module 8: Introduction to MDX Axes with integers SELECT [Measures].[Sales Amount] On 0, NonEmpty([Product Category].[Product Category Key].Members, [Measures].[Sales Amount]) On 1 FROM [Adventure Works] Run through the examples on the slide, explaining the structure of the result set that this will generate. Either display the result set as a demonstration or by drawing it on a whiteboard. Axes with names SELECT [Measures].[Sales Amount] On COLUMNS, NonEmpty([Product Category].[Product Category Key].Members, [Measures].[Sales Amount]) On ROWS FROM [Adventure Works]

7 Establishing Cube Context
Course 10778A Establishing Cube Context Module 8: Introduction to MDX SUBCUBE CREATE SUBCUBE Budget AS SELECT {[Account].[Account].&[4200], [Account].[Account].&[4300] } ON 0 FROM Budget Explain that the majority of MDX queries have a cube context that is the whole cube and nothing outside the cube. Highlight that the use of the LookupCube function can be detrimental to query performance. LOOKUPCUBE WITH MEMBER MEASURES.LOOKUPCUBEARCHIVE AS LOOKUPCUBE("AdventureWorksArchive", "[Measures].[Internet Sales Amount]") SELECT MEASURES.LOOKUPCUBEARCHIVE ON 0 FROM [Adventure Works] FILTER SELECT [Measures].[Sales Amount] ON 0, FILTER([Date].[Date].[Date].MEMBERS, [Measures].[Sales Amount]>1000) ON 1 FROM [Adventure Works]

8 Lesson 2: Adding Calculations to a Cube
Course 10778A Lesson 2: Adding Calculations to a Cube Module 8: Introduction to MDX The Calculations Tab of the Cube Designer Calculated Members Named Sets Useful MDX Functions (Non-Family Functions) Useful MDX Functions (Family Functions) Scoped Assignments

9 The Calculations Tab of the Cube Designer
Course 10778A The Calculations Tab of the Cube Designer Module 8: Introduction to MDX Form View Script View Explain the areas of the Calculations tab, explain the difference between form view and script view, and explain that you can switch between form view and script view as often as necessary. Calculated Member Form Editor Script Editor Script Organizer Calculation Tools

10 Module 8: Introduction to MDX
Course 10778A Calculated Members Module 8: Introduction to MDX

11 Module 8: Introduction to MDX
Course 10778A Named Sets Module 8: Introduction to MDX CALCULATE; CREATE MEMBER CURRENTCUBE.[Measures].[Total Sales Amount] AS [Measures].[Sales Amount - Internet Sales]+[Measures].[Sales Amount], FORMAT_STRING = "Currency", NON_EMPTY_BEHAVIOR = { [Sales Amount], [Sales Amount - Internet Sales] }, VISIBLE = 1 ; CREATE MEMBER CURRENTCUBE.[Measures].[Reseller GPM] AS ([Measures].[Sales Amount] - [Measures].[Total Product Cost]) / [Measures].[Sales Amount], FORMAT_STRING = "Percent", NON_EMPTY_BEHAVIOR = { [Sales Amount] }, CREATE DYNAMIC SET CURRENTCUBE.[Core Products] AS [Product Category].[English Product Category Name].&[Bikes] ;

12 Demonstration: Using Named Sets in a Cube
Course 10778A Demonstration: Using Named Sets in a Cube Module 8: Introduction to MDX In this demonstration, you will see how to: Define a Core Products named set Browse the cube by using the new named set Task 1: Define a Core Products named set Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod08 folder, run Setup.cmd as Administrator. In the D:\10778A\Demofiles\Mod08 folder, double-click click Adventure Works OLAP.sln to open it in SQL Server Data Tools. In Solution Explorer, right-click Adventure Works OLAP, and then click Deploy. If prompted, specify the user name ADVENTUREWORKS\Student and the password Pa$$w0rd. In Solution Explorer, double-click Adventure Works Cube.cube, and in the cube designer, click the Calculations tab. On the toolbar of the Calculations tab, click New Named Set. In the Name box, change the name of the new named set to [Accessories]. On the Metadata tab, in the Calculation Tools pane, expand Product, expand Product Category, expand Members, and then expand All. Drag Accessories into the Expression box. On the File menu, click Save All. Task 2: Browse the cube by using the new named set In SQL Server Data Tools, on the Build menu, click Deploy Adventure Works OLAP. If you see a warning that the database will be overwritten, click Yes. When deployment has successfully completed, click the Browser tab. In the Metadata pane, expand Measures, expand Reseller Sales, and then drag the Sales Amount – Reseller Sales measure to the Drag levels or measures here to add to the query area. In the Measure Group pane, expand the Product dimension, and then add the Product Category hierarchy to the left of Sales Amount. In the Measure Group pane, in the Product Category dimension, drag Accessories onto <Select dimension>. The data now shows only sales for accessories. Close SQL Server Data Tools..

13 Useful MDX Functions (Non-Family Functions)
Course 10778A Useful MDX Functions (Non-Family Functions) Module 8: Introduction to MDX CURRENTMEMBER NAME DIMENSION HIERARCHY LEVEL PARALLELPERIOD NONEMPTY Use additional functions if they are useful or relevant to the audience.

14 Useful MDX Functions (Family Functions)
Course 10778A Useful MDX Functions (Family Functions) Module 8: Introduction to MDX PARENT ANCESTOR FIRSTCHILD/LASTCHILD FIRSTSIBLING/LASTSIBLING Use additional functions if they are useful or relevant to the audience. USA CA WA Los Angeles San Diego San Francisco Redmond

15 Module 8: Introduction to MDX
Course 10778A Scoped Assignments Module 8: Introduction to MDX Scope ( [Date].[Fiscal Year].&[2010], [Date].[Fiscal].[Fiscal Quarter].Members, [Measures].[Sales Amount Quota] ) ; This = ParallelPeriod ( [Date].[Fiscal].[Fiscal Year], 1, [Date].[Fiscal].CurrentMember ) * 1.35 ; /*-- Allocate equally to months in FY */ ( [Date].[Fiscal Year].&[2009], [Date].[Fiscal].[Month].Members ) ; This = [Date].[Fiscal].CurrentMember.Parent / 3 ; End Scope ; Describe the use of subcubes and explain that SCOPE statements may not perform as required in ragged hierarchies.

16 Lesson 3: Using MDX to Query a Cube
Course 10778A Lesson 3: Using MDX to Query a Cube Module 8: Introduction to MDX Using MDX in SQL Server Management Studio Using MDX in Excel Using MDX in SQL Server Reporting Services

17 Using MDX in SQL Server Management Studio
Course 10778A Using MDX in SQL Server Management Studio Module 8: Introduction to MDX

18 Module 8: Introduction to MDX
Course 10778A Using MDX in Excel Module 8: Introduction to MDX

19 Using MDX in SQL Server Reporting Services
Course 10778A Using MDX in SQL Server Reporting Services Module 8: Introduction to MDX

20 Module 8: Introduction to MDX
Course 10778A Lab Scenario Module 8: Introduction to MDX Students will perform the lab in the role of a BI professional in the Adventure Works Cycles company, and: Create some MDX queries that return specific data from the cube Create an MDX calculated measure that calculates profit, and a calculated measure that returns gross profit margin. Point out that the instructions in the lab are deliberately designed to be high-level so that students need to think carefully about what they are trying to accomplish and work out how best to proceed for themselves. Encourage students to read the scenario information carefully and collaborate with each other to meet the scenario requirements. Remind students that if they find a particular task or exercise too challenging, they can find step-by-step instructions in the lab answer key. You are a BI developer for the Adventure Works Cycles company, and you are creating a custom analysis application for the Chief Finance Officer (CFO). The application must return sales data for products, customers, and dates from the Adventure Works Cube, so you have initially decided to experiment with MDX syntax to query the cube and retrieve business data. The CFO has also asked you to extend the cube to include measures for profit and gross profit margin, so you must create calculated members for these and ensure that you can include them in queries from the custom application you plan to build.

21 Module 8: Introduction to MDX
Course 10778A Lab 8: Using MDX Module 8: Introduction to MDX Exercise 1: Querying a Cube by Using MDX Exercise 2: Creating a Calculated Member In this lab, students will use MDX to extend the functionality of their Microsoft® SQL Server® Analysis Services (SSAS) solution. Exercise 1 In this exercise, students will query a cube by using MDX. Exercise 2 In this exercise, students will create a calculated member by using MDX. Logon information Virtual machine MIA-SQLBI User name ADVENTUREWORKS\Student Password Pa$$w0rd Estimated time: 30 minutes

22 Module Review and Takeaways
Course 10778A Module Review and Takeaways Module 8: Introduction to MDX What do you use MDX queries and expressions for in SQL Server? What are the three panes of the Calculations tab and what purpose does each pane serve? How can you create named sets? Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. Some guidance for discussing the answers to the questions is included below. What do you use MDX queries and expressions for in SQL Server? You use them to return data to a client application from an SSAS cube, format query results, perform cube design tasks, and perform administrative tasks, including dimension and cell security. What are the three panes of the Calculations tab and what purpose does each pane serve? You use the Script Organizer pane to create, organize, and select calculations for editing; the Calculation Tools pane provides metadata, functions, and templates with which to create calculations; the Calculation Expressions pane supports a form view and a script view. How can you create named sets? By using the New Named Set command on the Calculations tab of the Cube Designer.


Download ppt "Module 8: Introduction to MDX Module 8 Introduction to MDX"

Similar presentations


Ads by Google