Performing Advanced Set Construction

The MDX language provides access to some powerful if somewhat esoteric functions for building complex sets. In this final section of the chapter, you take a look at how two of these functions, Generate and Extract, can help you address common challenges.

Assembling Sets with the Generate Function

If you’ve worked with a procedural language such as C# or Visual Basic, you are familiar with the concept of a For Each loop. With a For Each loop, you iterate over the objects in a collection. For each of these objects, some operation is performed. Substitute a set of tuples for the collection of objects, use a set-building expression for the operations, and you’ve got the basic idea behind the Generate function:

Generate( ...

Get Microsoft® SQL Server® 2008 MDX Step by Step now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.