MDX Essentials : Set Functions: The DRILLDOWNMEMBER() Function
November 7, 2005
About the Series ...
This article is a member of the series, MDX Essentials. The series is designed to provide hands-on application of the fundamentals of the Multidimensional Expressions (MDX) language, with each tutorial progressively adding features designed to meet specific real-world needs. For more information about the series in general, please see my first article, MDX at First Glance: Introduction to MDX Essentials.
Note: To follow along with the steps we undertake within this and prospective articles of the series, the following components, samples and tools are recommended, and should be installed according to the respective documentation that accompanies MSSQL Server 2005:
Within MSSQL Server Analysis Services 2000, we had somewhat limited options (namely, the MDX Sample Application) for easily querying our cube data sources with MDX (at least, that is, options that were available "out of the box" to anyone who had simply installed Analysis Services and its samples). MSSQL Server 2005 offers us numerous means for querying our OLAP data sources. In the interest of working within the current environment, in this and the prospective articles of the series, we will construct and execute our MDX queries, in the most part, from the SQL Server Management Studio, but we will occasionally do so from the SQL Server Business Intelligence Studio, and perhaps from other vantage points, to further enrich the learning experience within the subject matter involved. For more in-depth information on any of these various "points of approach" themselves, see the relevant sections of the Books Online.
Virtually all of the MDX we constructed in earlier articles can now be used in the SQL Server Management Studio, SQL Server Business Intelligence Studio, and in various other areas within the Microsoft integrated Business Intelligence solution, and much of what we construct going forward can be executed in the MDX Sample Application (assuming connection to an appropriate Analysis Services 2000 OLAP data source). MDX as a language continues to evolve and expand: we will focus on many new features in articles to come, while still continuing to focus upon business uses of MDX in general. The use of MDX to meet the real-world needs of our business environments will continue to be my primary focus within the MDX Essentials series.
In this article, we will begin an extended examination of the MDX surrounding drilling up and down within our Analysis Services cubes. Comprising an analytical technique by which an information consumer can maneuver between summarized ("drilling up") and detailed ("drilling down") levels of data, drilling up or down occurs along the lines of drilling paths that are defined within the physical structures of our cubes. Often specified by the cube's dimensional hierarchies, these paths can also be based upon alternative relationships that exist within or between dimensions.
An example might be described as follows, based upon an engagement within which I have recently been involved: An executive within a state Department of Education wishes to examine annual Scholastic Aptitude Test (SAT) results within a cube constructed primarily to allow comparison and analysis of those results at various levels. The executive can examine national averages and numbers of test takers, and then perform a drilldown operation within a Geography dimension that might then present the data by states. He could then perform subsequent drilldowns to display state regions (or perhaps congressional districts), counties / school systems, and more. Depending upon the design of the cube, the drilldown process could ultimately take the consumer to the level of the individual schools - perhaps even to the individual students themselves.
Underneath the capability of Analysis Services to meet this common need is the DrillDownMember() function. DrillDownMember() drills down to the members within a specified set that are present within a second specified set. Working with two sets, the function thus inserts the children of the members of the primary set into a secondary set for members that are common to both specified sets, as we shall see. Typically, the primary set is a subset of the secondary set, but this is not a hard and fast rule.
DrillDownMember() can be used in conjunction with tuples within the sets. Through the provision of the RECURSIVE keyword, the function can be enabled to allow repeated comparison passes of the sets. The idea is to repeat set comparisons, and the resulting drilldowns, until no members / tuples that exist in both the specified primary and secondary sets, remain unexpanded, as we shall see within the discussion and hands-on practice session to follow.
In a manner similar to other functions that we have examined in the MDX Essentials series, DrillDownMember() can be useful in a host of different reporting and analysis applications. DrillDownMember(), along with other "navigational" functions like it (virtually all of which we examine in other articles of this series) allows us to exercise a great deal of presentation sleight of hand, in working with MDX in Analysis Services, as well as within Reporting Services and various other reporting applications that can access an Analysis Services cube.
The DrillDownMember() function can be leveraged within and among the various "layers" of the Microsoft integrated Business Intelligence solution to supporting sophisticated presentations and features. We will introduce the function, commenting upon its operation and touching upon examples of effects that we can employ it to deliver. As a part of our discussion, we will: