PacktLib: MDX with SSAS 2012 Cookbook

MDX with SSAS 2012 Cookbook


About the Authors

About the Reviewers


Elementary MDX Techniques


Putting data on x and y axes

Skipping axes

Using a WHERE clause to filter the data returned

Optimizing MDX queries using the NonEmpty() function

Using the PROPERTIES() function to retrieve data from attribute relationships

Basic sorting and ranking

Handling division by zero errors

Setting a default member of a hierarchy in the MDX script

Working with Sets


Implementing the NOT IN set logic

Implementing the logical OR on members from different hierarchies

Implementing the logical AND on members from the same hierarchy

Iterating on a set in order to reduce it

Iterating on a set in order to create a new one

Iterating on a set using recursion

Dissecting and debugging MDX queries

Working with Time


Calculating the YTD (Year-To-Date) value

Calculating the YoY (Year-over-Year) growth (parallel periods)

Calculating moving averages

Finding the last date with data

Getting values on the last date with data

Calculating today's date using the string functions

Calculating today's date using the MemberValue function

Calculating today's date using an attribute hierarchy

Calculating the difference between two dates

Calculating the difference between two times

Calculating parallel periods for multiple dates in a set

Calculating parallel periods for multiple dates in a slicer

Concise Reporting


Isolating the best N members in a set

Isolating the worst N members in a set

Identifying the best/worst members for each member of another hierarchy

Displaying few important members, others as a single row, and the total at the end

Combining two hierarchies into one

Finding the name of a child with the best/worst value

Highlighting siblings with the best/worst values

Implementing bubble-up exceptions



Detecting a particular member in a hierarchy

Detecting the root member

Detecting members on the same branch

Finding related members in the same dimension

Finding related members in another dimension

Calculating various percentages

Calculating various averages

Calculating various ranks

Business Analytics


Forecasting using the linear regression

Forecasting using the periodic cycles

Allocating the nonallocated company expenses to departments

Analyzing fluctuation of customers

Implementing the ABC analysis

When MDX is Not Enough


Using a new attribute to separate members on a level

Using a distinct count measure to implement histograms over existing hierarchies

Using a dummy dimension to implement histograms over nonexisting hierarchies

Creating a physical measure as a placeholder for MDX assignments

Using a new dimension to calculate the most frequent price

Using a utility dimension to implement flexible display units

Using a utility dimension to implement time-based calculations

Advanced MDX Topics


Displaying members without children (leaves)

Displaying members with data in parent-child hierarchies

Displaying random values

Displaying a random sample of hierarchy members

Displaying a sample from a random hierarchy

Performing complex sorts

Using recursion to calculate cumulative values

On the Edge


Clearing the Analysis Services cache

Using Analysis Services stored procedures

Executing MDX queries in T-SQL environments

Using SSAS Dynamic Management Views (DMV) to fast-document a cube

Using SSAS Dynamic Management View (DMVs) to monitor activity and usage

Capturing MDX queries generated by SSAS frontends

Performing a custom drillthrough