professional association for sql server · 2011-03-15 · queries to get the most out of ssrs erika...
TRANSCRIPT
![Page 1: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/1.jpg)
Sponsored by:
Professional Association for SQL ServerProfessional Association for SQL Server
Clever Queries: Crafting MDX
Queries to get the Most out of SSRS
Erika Bakse@BakseDoesBI
erikasblog.datainspirations.com
![Page 2: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/2.jpg)
Outline
• MDX Query
• With Clause
• Named Sets
• Calculated Members
• Think Outside the Cube!
![Page 3: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/3.jpg)
MDX Query
• The basic structure of the mdx query
• NB: In SSRS queries the columns MUST be measures
![Page 4: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/4.jpg)
Basic Query Syntax
SELECT
<Set> ON COLUMNS,
<Set> ON ROWS
FROM <Cube>
WHERE <Members>
![Page 5: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/5.jpg)
With Clause
• Where the fun happens!
• Create sets, members, measures
![Page 6: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/6.jpg)
With Clause Syntax
WITH
MEMBER Measures.MyMeasure AS <expression>
SET MySet AS <expression>
SELECT
<Set> ON COLUMNS,
<Set> ON ROWS
FROM <Cube>
WHERE <Members>
Add as many
calculations as you
need in WITH clause
Reference
calculations directly
or indirectly on
columns or rows
or in WHERE clause
![Page 7: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/7.jpg)
Named Sets
WITH
MEMBER MemberName AS <expression>
SET MySet AS <expression>
SELECT
<Set> ON COLUMNS,
<Set> ON ROWS
FROM <Cube>
WHERE <Members>
![Page 8: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/8.jpg)
Named Sets
• Set expression assigned to an alias
• Can be used throughout query wherever a set is usable
• Improve readability
• Simplify query changes
![Page 9: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/9.jpg)
Demo: Named Sets
![Page 10: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/10.jpg)
Calculated Members
WITH
MEMBER MemberName AS <expression>
SET MySet AS <expression>
SELECT
<Set> ON COLUMNS,
<Set> ON ROWS
FROM <Cube>
WHERE <Members>
![Page 11: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/11.jpg)
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…
![Page 12: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/12.jpg)
Demo: Dummy Members
![Page 13: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/13.jpg)
Demo: Think Outside the Cube!
![Page 14: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/14.jpg)
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
![Page 15: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/15.jpg)
Thank you to our sponsor
Professional Association for SQL ServerProfessional Association for SQL Server
![Page 16: Professional Association for SQL Server · 2011-03-15 · Queries to get the Most out of SSRS Erika Bakse @BakseDoesBI erikasblog.datainspirations.com. Outline • MDX Query • With](https://reader033.vdocument.in/reader033/viewer/2022041919/5e6b27661b18bc626e07d0d9/html5/thumbnails/16.jpg)
May 11-13, Orlando, FL
Oct 11-14, Seattle, WA
Save 25%: Register by April 12th
www.sqlpass.org/sqlrally
Register by March31st: save 40% and have the chance to win a cruise to Alaska!
“24HR11” code gets you $100 off
www.sqlpass.org/summit