Module 6: Creating and Manipulating Sets

78 401 0
Module 6: Creating and Manipulating Sets

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Contents Overview 1 Using Set Creation Functions 2 Lab A: Using Set Creation Functions 13 Using Set Manipulation Functions 20 Lab B: Using Set Manipulation Functions 30 Using Subquery Set Functions 36 Lab C: Using Subquery Set Functions 52 Working with Dimension Interactions 57 Lab D: Working with Dimension Interactions 64 Review 67 Module 6: Creating and Manipulating Sets BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Information in this document is subject to change without notice. The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted. Complying with all applicable copyright laws is the responsibility of the user. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation. If, however, your only means of access is electronic, permission to print one copy is hereby granted. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.  2000 Microsoft Corporation. All rights reserved. Microsoft, BackOffice, MS-DOS, Windows, Windows NT, <plus other appropriate product names or titles. Replace this example list with list of trademarks provided by copy editor. Microsoft is listed first, followed by all other Microsoft trademarks in alphabetical order. > are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries. Content developed by OLAP Train, Inc. for Microsoft Corporation and distributed under license. The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted. Other product and company names mentioned herein may be the trademarks of their respective owners. Module 6: Creating and Manipulating Sets iii BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Instructor Notes The ability to work with sets is critical both to retrieving data from an online analytical processing (OLAP) cube in a multidimensional expression (MDX) query statement and creating powerful MDX expressions. In this module, students will be introduced to functions that return sets of members. Some of the functions retrieve sets from the metadata defined in the cube's dimensions. Some of the functions manipulate those sets to create new sets that meet specific analytical purposes. After completing this module, students will be able to: ! Use functions to create a set. ! Use functions to manipulate a set. ! Create a set from subqueries. ! Manipulate dimension interactions by using advanced functions. Materials and Preparation This section provides you with the required materials and preparation tasks that are needed to teach this module. Required Materials To teach this module, you need the following materials: ! Microsoft ® PowerPoint ® file 2093A_6.ppt Preparation Tasks To prepare for this module, you should: ! Read all of the materials for this module. ! Read the instructor notes and margin notes. ! Practice the lecture and demonstrations. ! Complete the labs. ! Review the Teacher Preparation materials on the Teacher Preparation compact disc. Presentation: 95 Minutes Labs: 75 Minutes iv Module 6: Creating and Manipulating Sets BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Instructor Setup for Group Activities and Labs This section provides setup instructions that are required to prepare the instructor computer or classroom configuration for group activities and labs. All group activities and labs use the same database setup, which requires restoring a database archive. ! To prepare for group activities and labs In this procedure, you restore the Market database, which is a .cab file type. 1. Open Analysis Manager. 2. In the left pane, expand the Microsoft Analysis Services folder. 3. Expand the Server icon and verify that the Market database does not exist. 4. Right-click the Server icon, and then click Restore Database. 5. Navigate to the C:\Moc\2093A\Batches folder. 6. Select Market.cab, click Open, and then click Restore. If the Market database already exists from a previous group exercise or lab, and cubes within the database contain extraneous information, you can return the Market database and its cubes to a beginning position by either: Deleting any calculated members that were created in a specific cube, and then saving the cube. - or - Repeating the preceding restore database procedure. Module 6: Creating and Manipulating Sets v BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Other Activities Difficult Questions Below are difficult questions that students may ask you during the delivery of this module and answers to the questions. These materials delve into subjects that are within the scope of the module but are not specifically addressed in the content of the student notes. 1. Do the Members, Children, and Descendants function really create sets? These functions begin with something that is not a set—a dimension, a level, or a member—and return something that is a set. In that sense, they create sets. This is different from most other set functions, which begin with one or more sets and return a different set. 2. How would you get all the leaf-level members of an entire dimension? Use the Descendants function with the All Level member as the common ancestor. 3. Why do some functions—such as Children—follow a member while other functions—such as Descendants—include the member as an argument? In Microsoft Visual Basic ® terminology, why are some functions treated as properties while others are treated as methods? MDX functions do come in two forms: those that follow an object— properties; and those that take arguments—methods. There is no obvious reason for the difference. As a general rule, property-style functions don’t take arguments, whereas method-style functions usually do, but there are exceptions. As you learn a new function, you must remember its syntactic form. 4. The optional flags for the Descendants function can be confusing. Is there an easy way to learn them? In the first place, you can usually avoid using the flags of the Descendants function if you are willing to use combinations of other functions—particularly Union, Except, and Hierarchize. If you do want to use the Descendants flags, replace “before” with “above,” and “after” with “below,” and read the arguments in the order 1, 3, 2. For example, read the expression Descendants([1998],[Calendar Quarter],BEFORE_AND_AFTER) as “the descendants of 1998 above and below the calendar quarter level.” 5. The function definitions in the Syntax Examples list of the MDX2093A application do not always match those in the Functions list of the Calculated Member Builder. Which are correct? The MDX2093A application is simply a learning tool. It has many imperfections. Always use the Calculated Member Builder or Books Online to find and learn unfamiliar functions. vi Module 6: Creating and Manipulating Sets BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY 6. In both Books Online and the Functions list of the Calculated Member Builder, the syntax for the Descendants – Level function shows that you cannot use the third argument—Desc_flags—without also using the second argument—Level. Is that true? No. You can omit the Level argument, leaving commas to show its place, and still use a flag such as LEAVES as the third argument. The documentation is incorrect. 7. What are the different ways you can join together two sets, and what are the differences between them? There are three ways to combine two sets: the Union function, the plus operator (+), and simply enclosing the sets in braces. The plus operator requires an extra set of braces anyway, and there is no difference between using commas or plus signs to separate sets. The Union function can combine only two sets at a time, but it defaults to strip duplicate members. If you do want duplicate members, it may be easier to just combine the sets with braces. If you want to strip duplicate members, you may want to use the Union function. 8. Would you ever use the NON EMPTY keyword to create a calculated member? No. It is used only to create a query statement that returns a report. In a calculated member, you can use the NonEmptyCrossjoin function to combine sets from multiple dimensions and remove tuples that produce an empty result. Module 6: Creating and Manipulating Sets vii BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module Strategy Major sections of this module begin with or include a group activity followed by review lecture and then labs. The following are guidelines for delivering materials in the context of group activities: ! Using group activities to introduce new content You often introduce new concepts or functionality while delivering the procedures in a group activity as a live demonstration. For example, you may present a new MDX function by showing first its construction and then its result set as an actual calculated member formula or within a query statement. Use the topic slides that follow the group activity as a review of the content—for example, the syntax of a specific function. ! Interaction with students A group activity flows best when you deliver it as a shared exploration. Ask students such questions as: “What would happen if we…?” “Why did this happen?” “Was that what you expected?” Encourage students to ask you questions about the functions being tested. ! Students follow along In some cases, you may want to encourage students to follow your live demonstration on their own computers. This practice works best for simpler group activities or for a group activity that is not replicated by a later lab. It is not a problem if a student does not follow your demonstration, or if a student starts following and then stops before the group activity is completed. There is no file or structure dependency between group activities or between a group activity and a later lab. ! Lab replication of group activity The exercises in the labs closely follow the group activity procedures but do not define each step or show the code answer. Encourage students to write and test the MDX expressions on their own, referring back to the group activity procedures for clarification. Students may also refer to answer files, which are available for each procedure in exercises. Labs are generally more challenging when students have not followed the instructor on their own computers during the group activity. However, many students benefit from the two hands-on experiences of following the group activity and then completing the labs. ! Answer files for group activities Where applicable, answer files are provided for each procedure in group activities. If necessary to facilitate your demonstration, copy and paste the correct expression from the answer file into the Calculated Member Builder. viii Module 6: Creating and Manipulating Sets BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Use the following additional strategies to present this module: ! Using Set Creation Functions Begin by explaining why it is important to be able to create a set of members. Next, describe the use of the Members function, explaining the syntax carefully. Then introduce the Descendants function, describing how it can be used to retrieve members from either a single level or from multiple levels. Emphasize the fact that these functions are returning metadata about the cube, not data from the cube. ! Using Set Manipulation Functions Explain why it is useful to be able to manipulate sets to create a new set that contains specific members. Introduce the Head, Tail, Union, Intersect, Except, and Hierarchize functions, describing the syntax for each and giving examples of when to use each function. ! Using Subquery Set Functions Define the term subquery and describe when a subquery is used. Emphasize the difference between functions that look only at cube metadata and functions that use a subquery to retrieve actual data form the cube, although the function returns only a set of members and no actual data Introduce the Order, TopCount, and Filter functions, describing the syntax for each and explaining when to use each function. ! Working with Dimension Interactions Explain that this section introduces more advanced processes that retrieve sets that combine members from two or more dimensions. Then introduce the Crossjoin function and the NON EMPTY keyword. Describe the syntax for each and explain when to use each. Module 6: Creating and Manipulating Sets 1 BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Overview ! Using Set Creation Functions ! Using Set Manipulation Functions ! Using Subquery Set Functions ! Working with Dimension Interactions The ability to work with sets is critical both to retrieving data from an online analytical processing (OLAP) cube in a multidimensional expression (MDX) query statement and creating powerful MDX expressions. In this module, you will be introduced to functions that return sets of members. Some of the functions retrieve sets from the metadata defined in the cube's dimensions. Some of the functions manipulate those sets to create new sets that meet specific analytical purposes. After completing this module, you will be able to: ! Use functions to create a set. ! Use functions to manipulate a set. ! Create a set from subqueries. ! Manipulate dimension interactions by using advanced functions. Topic Objective To provide an overview of the module topics and objectives. Lead-in In this module, you will learn about the creation and manipulation of sets. 2 Module 6: Creating and Manipulating Sets BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY # ## # Using Set Creation Functions ! Group Activity: Using Set Creation Functions ! Members Function ! Children Function ! Single-Level Descendants Function ! Leaf-Level Descendants Function In this section, you will learn the most useful functions for retrieving a set of members from the metadata of a cube. These functions, when used alone, retrieve only sets of members from the cube metadata, not actual data from the cube. These sets can appear as labels on the axes of a report, controlling which cube values appear. In later sections, you will learn how to manipulate these simple sets of members. The group activity introduces the use of two basic functions that generate sets— the Members function and the Descendants function. The following topics follow the group activity: ! Members Function This topic describes how to return members of specified levels and dimensions by using the Members function. ! Children Function This topic describes the Children function. This function returns the children of a specified member. ! Single-Level Descendants Function This topic describes the Descendants function. The simplest form of this function returns a set of members at a specific level, lower in the hierarchy tree than the member and level names given in the query. You can also use the Descendants function to return all the members that descend from a single member. ! Leaf-Level Descendants Function The Descendants function can also be used to return a set of members from the lowest level of a dimension—the leaf-level members. To return a set that includes only leaf-level members, you use an optional third argument in the Descendants function. Topic Objective To introduce functions that retrieve a set of members from the metadata of a cube. Lead-in In this section, you will learn the most useful functions for retrieving a set of members from the metadata of a cube. Delivery Tip Briefly explain the bullets on this diamond slide to provide context for the upcoming group activity in which the items are functionally demonstrated. [...]... CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 6: Creating and Manipulating Sets 13 Lab A: Using Set Creation Functions Topic Objective To introduce the lab Lead-in In this lab, you will create sets by using the Members and Descendants functions Objectives Explain the lab objectives After completing this lab, you will be able to: ! Create sets by using the Members and Descendants functions Prerequisites... needed Manipulating a set allows you to answer new analytical questions BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 6: Creating and Manipulating Sets 21 Group Activity: Using Set Manipulation Functions Topic Objective To learn how to manipulate sets by using functions Lead-in In this group activity, you will learn how to manipulate existing sets to create new sets. .. requires two sets and includes an optional third argument 3 Delete the optional third argument, along with the comma and the brackets 4 Click in the first «Set» token, and then enter [Calendar Year].Members This expression returns a set of all the members of the Calendar Year level BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 6: Creating and Manipulating Sets 23 5 Click... 1 In the left pane of Analysis Manager, expand the Microsoft Analysis Services folder 2 Right-click the Server icon, and then click Restore Database 3 Navigate to the C:\Moc\2093A\Batches folder 4 Select Market.cab, click Open, and then click Restore BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 6: Creating and Manipulating Sets 15 ! To show all the members of a dimension... Examples list, expand the Set folder, and then double-click Children The Children function must follow a single member Do not confuse the Children function with the Members function A member has children A level or a dimension has members BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 6: Creating and Manipulating Sets 5 3 Click in the «Member» token and then type [Bagels].. .Module 6: Creating and Manipulating Sets 3 Group Activity: Using Set Creation Functions Topic Objective To learn how to create sets by using the Members and Descendants functions Lead-in In this group activity, you will learn how to generate sets of members In this group activity, you may follow along on your own computer... the Time.Calendar dimension except the quarters BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY 26 Module 6: Creating and Manipulating Sets Head and Tail Functions Topic Objective To describe Head and Tail functions ! Head Function $ Lead-in The Head and Tail functions extract a specified number of members from either the beginning or the end of a set Returns the specified... PURPOSES ONLY Module 6: Creating and Manipulating Sets 27 Union Function Topic Objective To describe the Union function ! Returns a Set That Is the Combination of Two Sets Lead-in ! Default Discards Duplicates; Optional ALL Retains Duplicates ! Equivalent to Enclosing Both Sets in Braces ! Appears in the Set Group of the Syntax Examples List The Union function allows you to combine any two sets from the... Prerequisites Before working on this lab, you must have successfully completed modules 1 through 5 in course 2093A, Implementing Business Logic with MDX in Microsoft SQL Server 2000 Estimated time to complete this lab: 15 minutes BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY 14 Module 6: Creating and Manipulating Sets Exercise 1 Using Set Creation Functions Delivery Tip The procedures... members occur on different levels None of the summarized members appears in the set BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY 8 Module 6: Creating and Manipulating Sets Members Function Topic Objective To explain the syntax and results of the Members function ! ! The Members function returns members of specific levels or dimensions Retrieves All Members of a Level or Dimension . of the module topics and objectives. Lead-in In this module, you will learn about the creation and manipulation of sets. 2 Module 6: Creating and Manipulating. function to combine sets from multiple dimensions and remove tuples that produce an empty result. Module 6: Creating and Manipulating Sets vii BETA MATERIALS

Ngày đăng: 04/11/2013, 13:15

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan