Introduction To MDX
Dustin Ryan
A little bit about me…
Business Intelligence Consultant,
Pragmatic Works
Technical editor for the many authors at
Pragmatic Works
Blog/Write @ www.BIDN.com
Proficient in magic
Part-time belly dancer at I-4 truck stop
About Pragmatic Works…
Located in sunny, stupid hot Green
Cove Springs, FL
Offer consulting and training services
Data Warehousing
Data Migrations
DTS Conversions
Software centering around Microsoft
B.I. stack
BI xPress
BIDS plugin for SSIS development
BI Documenter
Document reports, packages, cubes, databases
Task Factory
High performance SSIS tasks
What is MDX?
Multi Dimensional eXpression Language
Used to query cubes
(multidimensional databases)
Developed during the late 1990’s
Where is MDX used?
Cube calculations
KPI’s
Querying the cube
Why MDX?
Allows complex reporting
Cube answers analytical questions
Data is pre-aggregated
DEMO
Useful Terminology
Dimension
A Dimension organizes data in relation to a particular interest
Attribute
Within a dimension are attributes. Attributes are properties of the dimension that describe that area of interest.
Measures
A measure can be summarized as a column that contains some kind of quantifiable data that can be aggregated
More Useful Terminology
Hierarchy
A user defined hierarchy is a hierarchical structure of attributes
A couple more terms…
Level
Within a hierarchy are levels. An example of a level in the Date
Hierarchy would be the Month Level.
Member
A member is a value of a level. An example of a member of the
Month level would be March or April.
Yet More Useful Terms
Axis
Can be thought of as the line on a which a single dimension rests which intersects our measure groups
An MDX query can have up to 128 axes (only 5 are aliased)
Rows
Columns
Pages
Chapters
Sections
Most MDX queries contain only 2 axes since most reporting is done in a two dimensional tabular format
Basic MDX Query Syntax
MDX Query example:
Select [Date].[Fiscal Year].members on Rows ,
[Measures].[Internet Order Quantity] on Columns
From [Adventure Works]
Where [Product].[Category].&[1]
DEMO
Tuples & Sets
Tuples
A collection of dimension attributes not from the same dimension ex. ( [Date].[Fiscal Year].members, [Sales Territory].[Sales
Territory Country].members
)
Set
A collection of tuples ex. { ( [Date].[Fiscal Year].&[2006], [Sales Reason].[Sales
Reason].&[9] ) , ( [Date].[Fiscal Year].&[2006], [Sales
Reason].[Sales Reason].&[5] ) }
DEMO
Common MDX Calculations
DEMO
DEMO
MDX Books to Check Out
MDX Solutions
Microsoft SQL Server 2008 MDX
Step by Step
Practical MDX Queries by Art Tennick
Contact Me
Dustin Ryan
Email: dryan@pragmaticworks.com
Blog: www.BIDN.com/blogs/DustinRyan