MDX Solutions - .e-bookshelf.de

Transcription

01 748080 ffirs.qxp1/31/067:12 PMPage iMDX SolutionsSecond EditionWith Microsoft SQL Server AnalysisServices 2005 and Hyperion EssbaseGeorge SpoffordSivakumar HarinathChristopher WebbDylan Hai HuangFrancesco Civardi

01 748080 ffirs.qxp1/31/067:12 PMPage iv

01 748080 ffirs.qxp1/31/067:12 PMPage iMDX SolutionsSecond EditionWith Microsoft SQL Server AnalysisServices 2005 and Hyperion EssbaseGeorge SpoffordSivakumar HarinathChristopher WebbDylan Hai HuangFrancesco Civardi

01 748080 ffirs.qxp1/31/067:12 PMPage iiMDX Solutions, Second Edition: With Microsoft SQL Server Analysis Services 2005 andHyperion EssbasePublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.comCopyright 2006 by Wiley Publishing, Inc., Indianapolis, IndianaPublished simultaneously in CanadaISBN-13: 978-0-471-74808-3ISBN-10: 0-471-74808-0Manufactured in the United States of America10 9 8 7 6 5 4 3 2 12MA/RX/QS/QW/INNo part of this publication may be reproduced, stored in a retrieval system or transmitted in any formor by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except aspermitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the priorwritten permission of the Publisher, or authorization through payment of the appropriate per-copy feeto the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978)646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, WileyPublishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, oronline at http://www.wiley.com/go/permissions.Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations orwarranties with respect to the accuracy or completeness of the contents of this work and specificallydisclaim all warranties, including without limitation warranties of fitness for a particular purpose. Nowarranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that thepublisher is not engaged in rendering legal, accounting, or other professional services. If professionalassistance is required, the services of a competent professional person should be sought. Neither thepublisher nor the author shall be liable for damages arising herefrom. The fact that an organization orWebsite is referred to in this work as a citation and/or a potential source of further information doesnot mean that the author or the publisher endorses the information the organization or Website mayprovide or recommendations it may make. Further, readers should be aware that Internet Websiteslisted in this work may have changed or disappeared between when this work was written and whenit is read.For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993or fax (317) 572-4002.Library of Congress Catalog Nmuber: 2005032778Trademarks: Wiley and the Wiley logo are registered trademarks of John Wiley & Sons, Inc. and/or itsaffiliates, in the United States and other countries, and may not be used without written permission.Microsoft and SQL Server are trademarks or registered trademarks of Microsoft Corporation in theUnited States and/or other countries. Hyperion is a registered trademark of Hyperion Solutions Corporation. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is notassociated with any product or vendor mentioned in this book.Wiley also publishes its books in a variety of electronic formats. Some content that appears in print maynot be available in electronic books.

01 748080 ffirs.qxp1/31/067:12 PMPage iiiTo my wife, Lisa, and to my parents, for their care and love with theirchildren—George SpoffordI dedicate this book in the grandest possible manner to my dearwife Shreepriya, who has been fully supportive and put up with medisappearing from home or spent several late nights when I workedon this book. It is also dedicated to my two-month-old twins Praveenand Divya, who do not know yet what a book is. I wish their cutephotographs could be on the cover page. Finally, I would like todedicate this book to the memory of my father Harinath Govindarajaluwho passed away in 1999 who I am sure would have been proudof this great achievement and to my mother Sundara Bai.—Sivakumar HarinathFor Helen and Natasha—Chris WebbTo Alice, for your support and love.—Dylan Hai HuangI dedicate this book to my wife Teresa and my daughter Chiara, my mainsupporters in every challenge in my life. It is also dedicated to mycat Picci and its new friends Cartesio and Ipazia Hoppipolla for theirparticular attentions and their company during the writing of this book.—Francesco Civardi

01 748080 ffirs.qxp1/31/067:12 PMPage iv

01 748080 ffirs.qxp1/31/067:12 PMPage vAbout the AuthorsGeorge Spofford is a Distinguished Engineer at Hyperion Solutions, Inc. He hasbeen developing OLAP server and client software since 1998, when he led thedevelopment of FreeThink, one of the first desktop multidimensional modellingand analysis tools provided by Power Thinking tools, Inc. Upon its acquisitionby Computer Corporation of America, he became product architect for theirintegrated OLAP/data warehouse server. Subsequently, he co-founded the consulting firms Dimensional systems and DSS Lab, where he provided technologyconsulting, benchmark development and auditing, and development services tovendors and users alike of decision-support technology, including organizationssuch as AC Nielsen, IMS Health, Intel, Oracle, and Microsoft. He has writtennumerous articles for trade journals, spoken at trade shows, co-authored thebook Microsoft OLAP Solutions, and authored the first edition of MDX Solutions.george@dsslab.com.Sivakumar Harinath was born in Chennai, India. Siva has a Ph.D. in ComputerScience from the University of Illinois at Chicago. His thesis title was: “DataManagement Support for Distributed Data Mining of Large Datasets over HighSpeed Wide Area Networks.” Siva has worked for Newgen Software Technologies (P) Ltd., IBM Toronto Labs, Canada, and has been at Microsoft since February of 2002. Siva started as a Software Design Engineer in Test (SDET) in theAnalysis Services Performance Team and is currently an SDET Lead for Analysis Services 2005. Siva’s other interests include high performance computing,distributed systems and high-speed networking. Siva is married to Shreepriyaand had twins Praveen and Divya during the course of writing this book. Hispersonal interests include travel, games/sports (in particular, Chess, Carrom,Racquet Ball, Board games) and Cooking. You can reach Siva at sivakumar.harinath@microsoft.com.v

01 748080 ffirs.qxpvi1/31/067:12 PMPage viAbout the AuthorsChristopher Webb (cwebb olap@hotmail.com) has worked with MicrosoftAnalysis/OLAP Services since 1998 in a variety of roles, including three yearsspent with Microsoft Consulting Services. He is a regular contributor to themicrosoft.public.sqlserver.olap newsgroup and his blog can befound at http://spaces.msn.com/members/cwebbbi/.Dylan Hai Huang (Dylanh@microsoft.com) is currently working as a program manager in Microsoft Office Business Application Team. Before joiningthe current team, he had been working in Microsoft Analysis Service Performance Team. His main interests are business intelligence, high performancecomputation and data mining.Francesco Civardi (fcivardi@daisylabs.com, fcivardi@hotmail.com)is Chief Scientist at DaisyLabs, a Business Intelligence Company. He has beenworking with Microsoft Analysis/OLAP Services since 1999, in the financial,industrial and retail sectors. His main interests are mathematical and financialmodelling and Data Mining. He is Professor of Data Analysis Tools and Techniques at the Catholic University of Brescia and Cremona.

01 748080 ffirs.qxp1/31/067:12 PMPage viiCreditsExecutive EditorRobert M. ElliottDevelopment EditorEd ConnorTechnical EditorDeepak PuriProduction EditorAngela SmithCopy EditorFoxxe Editorial ServicesEditorial ManagerMary Beth WakefieldProduction ManagerTim TateVice President andExecutive Group PublisherRichard SwadleyVice President and ExecutivePublisherJoseph B. WikertProject CoordinatorRyan SteffenGraphics and Production SpecialistsDenny HagerJoyce HaugheyJennifer HeleineStephanie D. JumperAlicia SouthQuality Control TechniciansJohn GreenoughCharles SpencerBrian WallsProofreadingTECHBOOKS Production ServicesIndexingSherry Masseyvii

01 748080 ffirs.qxp1/31/067:12 PMPage viii

02 748080 ftoc.qxp1/31/067:13 PMPage ixContentsAcknowledgmentsIntroductionChapter 1xxixxiiiA First Introduction to MDXWhat Is MDX?Query BasicsAxis Framework: Names and NumberingCase Sensitivity and LayoutSimple MDX ConstructionComma (,) and Colon (:).MembersGetting the Children of a Member with .ChildrenGetting the Descendants of a Member with Descendants()Removing Empty Slices from Query ResultsComments in MDXThe MDX Data Model: Tuples and SetsTuplesSetsQueriesQueries with Zero AxesAxis-Only QueriesMore Basic VocabularyCrossJoin()Filter()Order()Querying for Member PropertiesQuerying Cell PropertiesClient Result Data 0323435ix

02 748080 ftoc.qxpx1/31/067:13 PMPage xContentsChapter 2Introduction to MDX Calculated Members and Named SetsDimensional Calculations As Calculated MembersCalculated Member ScopesCalculated Members and WITH Sections in QueriesFormula Precedence (Solve Order)Basic Calculation FunctionsArithmetic OperatorsSummary Statistical OperatorsAvg()Count(), .CountDistinctCount() (Microsoft extension)Sum()Max()Median()Min()NonEmptyCount() (Hyperion extension)Stdev(), Stddev()StdevP(), StddevP() (Microsoft Extension)Var(), Variance()VarP(), VarianceP() (Microsoft Extension)Additional FunctionsIntroduction to Named SetsNamed Set ScopesChapter mary60Common Calculations and Selections in MDX61Metadata Referencing Functions in MDXMany Kinds of Ratios, Averages, Percentages, and AllocationsPercent Contribution (Simple Ratios between Levelsin a Hierarchy)Percent Contribution to TotalUsing the .CurrentMember functionUsing the .Parent functionTaking the Share-of-Parent Using .CurrentMember and.ParentUsing the Ancestor() functionCalculating the Share-of-Ancestor using .CurrentMemberand Ancestor()Handling Division by ZeroBasic AllocationsProportional Allocation of One QuantityBased on Ratios of AnotherUnweighted Allocations down the HierarchyAveragesSimple AveragesWeighted AveragesTime-Based References and Time-Series CalculationsPeriod-to-Period References and CalculationsSame-Period-Last-Year References and Calculations64656566666667676769707071717273747576

02 748080 ftoc.qxp1/31/067:13 PMPage xiContentsYear-to-Date (Period-to-Date) AggregationsRolling Averages and 52-week High/LowUsing LastPeriods() to Select Time Ranges Basedon a Target MemberDifferent Aggregations along Different Dimensions(Semi-Additive Measures Using MDX)Mixing Aggregations: Sum across Non-Time, Average/Min/Max along TimeMixing Aggregations: Sum across Non-time, Opening/Closing Balance along TimeCarryover of Balances for Slowly Changing Valuesand Reporting of Last Entered BalanceFinding the Last Child/Descendant with DataFinding the Last Time Member for Which Any DataHas Been EnteredUsing Member Properties in MDX Expressions(Calculations and Sorting)Handling Boundary Conditions (Members out of Range,Division by Zero, and More)Handling Insufficient Range SizeHandling Insufficient Hierarchical DepthHandling a Wrong-Level ReferenceHandling Division by ZeroChapter 4767981828283848788899293939495Summary95MDX Query Context and ExecutionCell Context and Resolution Order in Queries9798The Execution Stages of a QueryThe .DefaultMember FunctionDefault Context and SlicersThe Simplest Query: All Context, Nothing ElseThe WHERE Clause: Default Context and SlicersAdding Axes to a QueryCell Context When Resolving AxesOverriding Slicer ContextCell Evaluation (For Any Cell)Drilling in on Solve Order and Recursive EvaluationResolving NON EMPTY AxesResolving the HAVING Clause in AS2005Looping Context and .CurrentMemberInterdependence of Members in AS2005: Strong Hierarchies,Autoexists, and Attribute RelationshipsStrong HierarchiesAutoexistsModifying the Cube Context in AS2005CREATE SUBCUBE DescribedSubcube Restrictions and Attribute RelationsFurther Details of Specifying a SubcubeTuple Specifications for 16118119120123125125xi

02 748080 ftoc.qxpxii1/31/067:13 PMPage xiiContentsSubcubes Based on Data ValuesSubcubes for Iterative Query RefinementPoints to Consider When Using SubcubesUsing SELECT in the FROM Clause in AS2005Infinite Recursion: A “Gotcha” Related to Calculation ContextProduct-Specific Solve Order UseUse of Solve Order between Global, Session, andQuery Calculations in Analysis Services 2005Use of Solve Orders in EssbaseUse of Solve Orders in Analysis Services 2000Nondata: Invalid Numbers, NULLs, and Invalid MembersInvalid Calculations: Division by Zero and Numerical ErrorsSemantics of Empty CellsNULLs in Comparisons and CalculationsInvalid LocationsPrecedence of Cell Properties in CalculationsPrecedence of Display FormattingData Types from Calculated CellsChapter 5Chapter 44Cube Context in ActionsCube Context in KPIsVisibility of Definitions between Global, Session, andQuery-Specific Calculations in Analysis Services 2005Summary146146146148Named Sets and Set AliasesNamed Sets: Scopes and ContextCommon Uses for Named SetsSet Aliases149149150152An Example of a Set AliasSet Aliases in More DetailWhen Se

Services 2005 and Hyperion Essbase 01_748080 ffirs.qxp 1/31/06 7:12 PM Page i. 01_748080 ffirs.qxp 1/31/06 7:12 PM Page iv. George Spofford Sivakumar Harinath Christopher Webb Dylan Hai Huang Francesco Civardi MDX Solutions Second Edition With Microsoft SQL Server Analysis Services 2005 and Hyperion Essbase 01_748080 ffirs.qxp 1/31/06 7:12 PM Page i. C1.jpg. MDX Solutions, Second .