1 / 15

Mastering MDX: Querying with Named Sets & Calculated Members

Dive into the world of MDX (Multidimensional Expressions) and learn how to effectively use the WITH clause to define calculated members and named sets. Understanding the foundational structure of MDX queries can significantly enhance your data analysis skills in SQL Server Reporting Services (SSRS). This guide covers basic query syntax, how to create reusable sets and calculations, and demonstrates practical examples to improve readability and simplify complex queries. Discover essential functions like Rank and Item to manipulate data in your queries.

bart
Download Presentation

Mastering MDX: Querying with Named Sets & Calculated Members

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Think Outside the Group! Erika Bakse @BakseDoesBI erikasblog.datainspirations.com

  2. Outline MDX Query With Clause Named Sets Calculated Members “Location” Functions Think Outside the Group!

  3. MDX Query The basic structure of the MDX query NB: In SSRS queries the columns MUST be measures

  4. Basic Query Syntax SELECT <Set> ON COLUMNS, <Set> ON ROWSFROM <Cube> WHERE <Members>

  5. With Clause Where the fun happens! Create sets, members, measures

  6. With Clause Syntax Add as many calculations as you need in WITH clause WITH MEMBER Measures.MyMeasure AS <expression> SET MySetAS <expression> SELECT <Set> ON COLUMNS, <Set> ON ROWSFROM <Cube> WHERE <Members> Reference calculations directly or indirectly on columns or rows or in WHERE clause

  7. Named Sets WITH MEMBER MemberNameAS <expression> SET MySetAS <expression> SELECT <Set> ON COLUMNS, <Set> ON ROWSFROM <Cube> WHERE <Members>

  8. Named Sets Set expression assigned to an alias Can be used throughout query wherever a set is usable Improve readability Simplify query changes

  9. Demo: Named Sets

  10. Calculated Members WITH MEMBER MemberNameAS <expression> SET MySetAS <expression> SELECT <Set> ON COLUMNS, <Set> ON ROWSFROM <Cube> WHERE <Members>

  11. Calculated Members MemberNameis the fully qualified name of the calculated member, including the dimension Commonly used to create calculated measures Can really be defined as just about anything…

  12. Demo: Dummy Members

  13. “Location” Functions • Where is a tuple “located” in a set? • Rank() • 1-based index • Rank(<TupleExpression>, <SetExpression>) • Return a tuple from a particular location in a set • Item • 0-based index • <SetExpression>.Item(Index)

  14. Demo: Think Outside the Group!

  15. Resources Creating Named Sets http://msdn.microsoft.com/en-us/library/aa216742(v=sql.80).aspx Creating Calculated Members http://msdn.microsoft.com/en-us/library/aa216747(v=SQL.80).aspx MDX Essentials, William Pearson http://www.databasejournal.com/features/mssql/article.php/1495511/MDX-at-First-Glance-Introduction-to-SQL-Server-MDX-Essentials.htm

More Related