Multidimensional Expressions (MDX) Reference SQL Server 2012 Books Online
Total Page:16
File Type:pdf, Size:1020Kb
Multidimensional Expressions (MDX) Reference SQL Server 2012 Books Online Summary: Multidimensional Expressions (MDX) is the query language that you use to work with and retrieve multidimensional data in Microsoft Analysis Services. MDX is based on the XML for Analysis (XMLA) specification, with specific extensions for SQL Server Analysis Services. MDX utilizes expressions composed of identifiers, values, statements, functions, and operators that Analysis Services can evaluate to retrieve an object (for example a set or a member), or a scalar value (for example, a string or a number). Category: Reference Applies to: SQL Server 2012 Source: SQL Server Books Online (link to source content) E-book publication date: June 2012 Copyright © 2012 by Microsoft Corporation All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Contents Multidimensional Expressions (MDX) Reference ................................................................................. 8 MDX Syntax Elements .................................................................................................................................... 8 Identifiers ...................................................................................................................................................... 10 Using Regular Identifiers ..................................................................................................................... 10 Using Delimited Identifiers ................................................................................................................. 11 Expressions ................................................................................................................................................... 12 Using Cube and Subcube Expressions ........................................................................................... 14 Using Dimension Expressions ........................................................................................................... 16 Using Member Expressions ................................................................................................................ 17 Using Tuple Expressions ...................................................................................................................... 18 Using Set Expressions........................................................................................................................... 19 Using Scalar Expressions ..................................................................................................................... 20 Working with Empty Values ............................................................................................................... 22 Operators (MDX Syntax) ......................................................................................................................... 25 Arithmetic Operators ............................................................................................................................ 28 Bitwise Operators ................................................................................................................................... 29 Comparison Operators ........................................................................................................................ 29 Concatenation Operators ................................................................................................................... 31 Set Operators .......................................................................................................................................... 31 Unary Operators ..................................................................................................................................... 32 Assignment Operators ......................................................................................................................... 33 Functions (MDX Syntax) .......................................................................................................................... 33 Using String Functions ......................................................................................................................... 35 Using Mathematical Functions ......................................................................................................... 37 Using Logical Functions ....................................................................................................................... 37 Using Member Functions .................................................................................................................... 38 Using Tuple Functions .......................................................................................................................... 39 Using Set Functions .............................................................................................................................. 39 Using Dimension, Hierarchy, and Level Functions .................................................................... 43 Using Stored Procedures .................................................................................................................... 44 Comments (MDX Syntax) ........................................................................................................................ 44 Reserved Keywords (MDX Syntax) ...................................................................................................... 46 MDX Language Reference .......................................................................................................................... 46 MDX Syntax Conventions ....................................................................................................................... 47 MDX Statement Reference ..................................................................................................................... 48 MDX Scripting Statements ................................................................................................................. 48 MDX Data Definition Statements..................................................................................................... 54 MDX Data Manipulation Statements.............................................................................................. 94 MDX Operator Reference .................................................................................................................... 113 -- (Comment) ........................................................................................................................................ 115 - (Except) ................................................................................................................................................ 117 - (Negative) ........................................................................................................................................... 118 - (Subtract)............................................................................................................................................. 119 * (Crossjoin) ........................................................................................................................................... 120 * (Multiply) ............................................................................................................................................. 121 / (Divide) ................................................................................................................................................. 122 ^ (Power)................................................................................................................................................ 124 /*...*/ (Comment) ................................................................................................................................. 125 // (Comment) ........................................................................................................................................ 126 : (Range) ................................................................................................................................................. 127 + (Add) .................................................................................................................................................... 128 + (Positive)............................................................................................................................................. 129 + (String Concatenation) ................................................................................................................