Sponsored by: Professional Association for SQL Server. Clever Queries: Crafting
MDX. Queries to get the Most out of SSRS. Erika Bakse. @BakseDoesBI.
Professional Association for SQL Server
Clever Queries: Crafting MDX Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com
Sponsored by:
Outline • • • • •
MDX Query With Clause Named Sets Calculated Members Think Outside the Cube!
MDX Query • The basic structure of the mdx query • NB: In SSRS queries the columns MUST be measures
Basic Query Syntax
SELECT ON COLUMNS, ON ROWS FROM WHERE
With Clause • Where the fun happens! • Create sets, members, measures
With Clause Syntax Add as many calculations as you need in WITH clause
WITH MEMBER Measures.MyMeasure AS SET MySet AS SELECT ON COLUMNS, Reference ON ROWS calculations directly FROM or indirectly on columns or rows WHERE or in WHERE clause
Named Sets WITH MEMBER MemberName AS SET MySet AS SELECT ON COLUMNS, ON ROWS FROM WHERE
Named Sets • • • •
Set expression assigned to an alias Can be used throughout query wherever a set is usable Improve readability Simplify query changes
Demo: Named Sets
Calculated Members WITH MEMBER MemberName AS SET MySet AS SELECT ON COLUMNS, ON ROWS FROM WHERE
Calculated Members • MemberName is 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…
Demo: Dummy Members
Demo: Think Outside the Cube!
Resources • Creating Named Sets http://msdn.microsoft.com/enus/library/aa216742(v=sql.80).aspx • Creating Calculated Members http://msdn.microsoft.com/enus/library/aa216747(v=SQL.80).aspx • MDX Essentials, William Pearson http://www.databasejournal.com/features/mssql/article.ph p/1495511/MDX-at-First-Glance-Introduction-to-SQLServer-MDX-Essentials.htm
Professional Association for SQL Server
Thank you to our sponsor
Save 25%: Register by April 12th
May 11-13, Orlando, FL
www.sqlpass.org/sqlrally
Register by March31st: save 40% and have the chance to win a cruise to Alaska!
Oct 11-14, Seattle, WA
“24HR11” code gets you $100 off www.sqlpass.org/summit