Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Feb 6, 2006

MDX Set Functions: DrillDownLevel()

By William Pearson

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:

  • Microsoft SQL Server 2005 Database Engine (for the accompanying SQL Server Management Studio);

  • Microsoft SQL Server 2005 Analysis Services;

  • Business Intelligence Development Studio;

  • The Analysis Services AdventureWorks DW sample database (fully deployed to Analysis Services from the AdventureWorks DW Analysis Services project that accompanies Analysis Services 2005).

The MSSQL Server 2005 and Analysis Services 2005 samples to which I refer above are available within a Microsoft Windows Installer package that accompanies the respective applications on the installation CDs, or which can be downloaded from Microsoft and perhaps elsewhere. The samples are not installed by default. If you did not install the samples and the AdventureWorks sample database during SQL Server 2005 Setup, you can install them after Setup finishes. For more information, see the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" in the SQL Server Books Online. Make sure that you read and follow the installation instructions in the Readme files that accompany the samples that you want to install. For a list of samples, see the topic "Samples" in the SQL Server Books Online.

To successfully replicate the steps of the article, you also need to be a member of the appropriate group / role in Analysis Services to access the sample cube for our exercises. Read permissions are assumed for the samples upon which we will base our practice exercises, where we will often be using the AdventureWorks cube, which arrives with Analysis Services 2005 within the AdventureWorks DW Analysis Services project.

Current Service Pack updates are assumed for the operating system, MSSQL Server 2005 ("MSSQL Server"), MSSQL Server 2005 Analysis Services ("Analysis Services"), MSSQL Server 2005 Reporting Services ("Reporting Services") and the related Books Online and Samples. Images are from a Windows 2003 Server environment, but the steps performed in the articles, together with the views that result, will be quite similar within any environment that supports MSSQL Server 2005 and its component applications.

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. In addition, 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 consider 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 continue our examination, begun in Set Functions: The DRILLDOWNMEMBER() Function, of the MDX surrounding drilling up and down within our Analysis Services cubes. As we have noted, drilling up or down occurs along the lines of drilling paths that are defined within the physical structures of our cubes, and comprises an analytical technique by which an information consumer can maneuver between summarized ("drilling up") and detailed ("drilling down") levels of data. While these drilling paths are typically defined by the cube's dimensional hierarchies, they can also be based upon alternative relationships that exist within or between dimensions.

A general example, which I have used within sister articles surrounding the MDX "drilling" functions, might be extended 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 Graduation Rates within a cube constructed primarily to allow comparison and analysis of those rates at various levels. The executive can examine national rates and numbers of graduates, 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 information consumer to the level of the individual schools – perhaps even to the individual students themselves (assuming a world without privacy concerns, of course).

In Set Functions: The DRILLDOWNMEMBER() Function, we discussed that, underneath the capability of Analysis Services to meet this common need is the DrillDownMember() function. Another "staple" support function underpinning drill down capabilities is the DrillDownLevel() function, which will form the subject of this article. DrillDownLevel() drills down the members of a set to a lower level, and additionally offers us the flexibility to specify which level below a given member in the set, as we shall see. In its simplest use, based upon a set we specify, DrillDownLevel() returns a set of child members, each of which is included immediately under its respective parent member. DrillDownLevel() also affords us the option to narrow the children we return to only the members of a given level, if that is desirable.

In addition to its default behavior of taking a set specification as an argument, and drilling down to reveal the members of the level underneath (where appropriate), DrillDownLevel() can accept an additional Level argument to allow us to direct drilldown to a specific level, instead of simply drilling to the immediately "next" level, as we shall see. (We can alternatively supply an index to further control the behavior of the DrillDownLevel() function in targeting a specific level).

In a manner similar to other functions that we have examined in the MDX Essentials series, DrillDownLevel() can be useful in a host of different reporting and analysis applications. DrillDownLevel(), 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.

As we have seen to be the case with other members of the "family" of drill-related functions, as well as with many other MDX functions in general, the DrillDownLevel() function can be leveraged, within and among the various "layers" of the Microsoft integrated Business Intelligence solution, to support 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:

  • Examine the syntax surrounding the function;
  • Undertake illustrative examples of the uses of the function in practice exercises;
  • Briefly discuss the results datasets we obtain in the practice examples.

MS SQL Archives

Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM