dcsimg

MDX Set Functions: DrillDownLevel() - Page 5

February 6, 2006

The report authors outline the next drilldown scenario as follows: using the Adventure Works cube, once again, as a data source, they wish to create a query that returns information surrounding the composition of select sales from the perspective of customer locations. Specifically, they wish to present comparative Internet Sales for all Calendar Years contained in the cube, for United States customers, in such a way that the states within which sales took place are summarized. The drilldown requirement in this case consists in the need to present the total sales for the United States, drilled down to the sales totals for the states, which make up the U.S. total. The report authors are convinced that, once they achieve this objective, the capability to perform ad hoc drilldowns on a given state (or a group of states) at runtime will become a matter of parameterizing the key component of the row axis specification within the MDX query involved, a mechanism that can be leveraged, as one example, in a summary / target report pairing (as well as through other avenues) within Reporting Services, such as we have discussed earlier.

To outline the requirement further, our "confirmation of understanding draft," again in MS Excel, is depicted in Illustration 12.


Illustration 12: "Confirmation Draft" of the Proposed Dataset

We obtain consensus on the dataset, and set about constructing the query.

4.  Replace the syntax from our initial query in the Query pane by typing (or cutting and pasting) the following in its place:


--- MDX040-002-1 DrillDownLevel() 
 With Level Expression Option - Before
SELECT
 CROSSJOIN({[Date].
 [Calendar Year].Members},{[Measures].
   [Internet Sales Amount]}) ON COLUMNS,
 NON EMPTY(DRILLDOWNLEVEL( {
   [Customer].[Customer Geography].
   [Country].[United States]}
 )) ON ROWS
FROM 
  [Adventure Works]

The Query pane appears, with our input, as shown in Illustration 13.


Illustration 13: Second Query in the Query Pane ...

5.  Select File --> Save MDX040-001 As..., name the file MDX040-002-1, and place it in a meaningful location, to protect the former query.

6.  Execute the query by clicking the Execute button in the toolbar, as before.

The Results pane is populated by Analysis Services, and the dataset shown in Illustration 14 appears.


Illustration 14: Results Dataset – Another Basic Use of DrillDownLevel() Function

In the returned dataset, we see that Country United States (the top row of the dataset) is presented in "rolled up" state. The states, within which we have conducted Internet Sales transactions, within the Calendar Years contained within the Adventure Works cube, appear underneath the United States summary line. The states represent the drilled down children of Country United States, whose values add up to the Country United States total. The query has returned the "next level down" from the United States level, or all States with activity. This, as we have discussed, is the default, most straightforward use of DrillDownLevel().

7.  Select File --> Save MDX040-002-1.mdx to ensure that the file is saved. (Leave MDX040-002-1.mdx open for the next steps).

The developers / authors again express satisfaction with the results, agreeing that the current point is a good place from which to demonstrate the use of the optional Level Expression option that we have explained to them in introductory discussions. We agree that a useful next step will be a further extension of the query. As an example of the process involved, the developers / authors wish to see how they might easily make it possible to leverage the Level Expression to direct the function to return members from a specific level underneath the Country United States set ( {[Customer].[Customer Geography].[Country].[United States]} ). As an illustrative example, they wish to direct drill down explicitly to the City level from the current point, and to therefore return the child Cities (with values) for each of the States currently presented, and to display their sales contributions, in turn, to the United States Internet Sales total.

We reiterate that the optional Level Expression exists specifically for this purpose, and take the following steps to demonstrate its operation.

8.  Modify the top line in the query (the commented line) to the following:

--- MDX040-002-2 DrillDownLevel() With Level Expression Option - "After"

9.  Select File --> Save MDX040-002-1 As..., name the file MDX040-002-2, placing it with the previous to query files, to protect the former query.

10.  Place a comma (",") after the existing Set Expression within the Rows axis specification (That is, {[Customer].[Customer Geography].[Country].[United States]} ).

11.  Create a space below [Customer].[Customer Geography].[Country].[United States] using the Enter key just after the newly added comma, pushing down the row containing the ON ROWS keywords in the process.

12.  Insert the following into the space below (between the existing Set Expression and the ON ROWS keywords)

 [Customer].[Customer Geography].[State-Province]

The Query pane appears, with the areas affected by our modifications circled, as depicted in Illustration 15.


Illustration 15: Our Second Query, with Modifications

13.  Execute the query by clicking the Execute button in the toolbar, as we did earlier.

The Results pane is populated by Analysis Services, and the dataset partially shown in Illustration 16 appears.


Illustration 16: Results Dataset (Partial View) – Level Expression at Work ...

Country United States is, indeed, drilled down to child Cities containing sales values, whose individual sales totals make up the summary United States total for each Calendar Year. As we noted to be the case with the Set Expression in the ROWS axis specification in earlier examples, the added Level Expression can also be subjected to parameterization within a reporting (or other) application, for far-reaching capabilities with regard to manipulation of the supporting dataset of a target report containing the DrillDownLevel() function under consideration.

The report authors state that their immediate goals have been met. We agree to return at a later time to demonstrate approaches to implement the DrillDownLevel() function in Reporting Services to leverage MDX to support interactive drilldown by organizational information consumers.

14.  Select File --> Save MDX040-002-2.mdx to save our work.

15.  Select File --> Exit to leave the SQL Server Management Studio, when ready.

Summary ...

In this article, we continued our extended examination of the MDX surrounding drilling up and down within our Analysis Services cubes, focusing upon the DrillDownLevel() function. We noted that 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 introduced the function, commenting upon its operation and touching upon examples of effects that we can employ it to deliver to empower information consumers to maneuver between summarized and detailed levels of data.

As a part of our examination of the DrillDownLevel() function, we commented upon its operation and touched upon the "extended" datasets we can deliver using the function with a specified Set Expression and optional Level Expression (as well as discussing its default behavior when no Level Expression is specified). We also discussed the Index option, and how it supports further control over drilldown between levels. Next, we examined the syntax involved with DrillDownLevel(), and then undertook a couple of illustrative practice examples within which we met hypothetical business requirements with the function, generating queries that capitalized on its primary features. Further, we discussed points within our query where we might consider the insertion of parameterization in a reporting application (or other consumer application), such as Reporting Services, to leverage the function to support drilldown in an ad hoc manner. Throughout our practice session, we briefly discussed the results datasets we obtained from each of the queries we constructed.

» See All Articles by Columnist William E. Pearson, III

Discuss this article in the MSSQL Server 2000 Analysis Services and MDX Topics Forum.

MDX Essentials Series
The LEVEL_NUMBER Member Property
The LEVEL_UNIQUE_NAME Intrinsic Member Property
Intrinsic Member Properties: The HIERARCHY_UNIQUE_NAME Property
Intrinsic Member Properties: The DIMENSION_UNIQUE_NAME Property
Further Combination of BottomCount() with Other MDX Functions
Combine BottomCount() with Other MDX Functions to Add Sophistication
Basic Set Functions: The BottomCount() Function, Part I
Intrinsic Member Properties: The MEMBER_VALUE Property
Intrinsic Member Properties: The MEMBER_UNIQUE_NAME Property
Intrinsic Member Properties: The MEMBER_NAME Property
Intrinsic Member Properties: The MEMBER_KEY Property
Intrinsic Member Properties: The MEMBER_CAPTION Property
Set Functions: The StripCalculatedMembers() Function
Set Functions: The AddCalculatedMembers() Function
MDX Numeric Functions: The Min() Function
MDX Numeric Functions: The Max() Function
Set Functions: The .AllMembers Function
MDX Essentials: Set Functions: The MeasureGroupMeasures() Function
String Functions: The .Properties Function, Part II
String Functions: The .Properties Function
Logical Functions: IsGeneration(): Conditional Logic within Filter Expressions
MDX Scripting Statements: Introducing the Simple CASE Statement
Logical Functions: IsGeneration(): Conditional Logic within Calculations
Logical Functions: IsAncestor(): Conditional Logic within Filter Expressions
MDX Clauses and Keywords: Use HAVING to Filter an Axis
Logical Functions: IsAncestor(): Conditional Logic within Calculations
Logical Functions: IsSibling(): Conditional Logic within Filter Expressions
Logical Functions: IsSibling(): Conditional Logic within Calculations
MDX Operators: The IsLeaf() Operator: Conditional Logic within Filter Expressions
MDX Operators: The IsLeaf() Operator: Conditional Logic within Calculations
MDX Numeric Functions: The .Ordinal Function
Other MDX Entities: Perspectives
MDX Operators: The IS Operator
MDX Set Functions: The Distinct() Function
MDX Set Functions: The ToggleDrillState() Function
Set Functions: The DrillUpLevel() Function
Set Functions: The DrillDownLevelTop() and DrillDownLevelBottom() Functions
MDX Set Functions: DrillDownLevel()
MDX Set Functions: The DRILLUPMEMBER() Function
MDX Essentials: Set Functions: The DRILLDOWNMEMBERTOP() and DRILLDOWNMEMBERBOTTOM() Functions
MDX Essentials : Set Functions: The DRILLDOWNMEMBER() Function
MDX Essentials: Drilling Through with MDX: The DRILLTHROUGH Statement
MDX Essentials: String Functions: The .UniqueName Function
MDX Essentials: String Functions: The .Name Function
MDX Essentials: String / Numeric Functions: The CoalesceEmpty() Function
MDX Essentials: Basic Set Functions: The TopCount() Function, Part II
MDX Essentials: Basic Set Functions: The TopCount() Function, Part I
MDX Essentials: Enhancing CROSSJOIN() with Calculated Members
MDX Essentials: Set and String Functions: The GENERATE() Function
MDX Essentials: The CROSSJOIN() Function: Breaking Bottlenecks
MDX Essentials: String / Numeric Functions: More on the IIF() Function
MDX Essentials: String / Numeric Functions: Introducing the IIF() Function
MDX Essentials: Logical Functions: The IsEmpty() Function
MDX Essentials: Basic Set Functions: The EXTRACT() Function
MDX Essentials: Numeric Functions: Introduction to the AVG() Function
MDX Essentials: Basic Member Functions: The .Item() Function
MDX Essentials: Basic Set Functions: Subset Functions: The Subset() Function
MDX Essentials: Basic Set Functions: Subset Functions: The Tail() Function
MDX Essentials: Basic Set Functions: Subset Functions: The Head() Function
MDX Essentials: Basic Set Functions: The CrossJoin() Function
MDX Essentials: Basic Numeric Functions: The Count() Function
MDX Essentials: Basic Set Functions: The Filter() Function
MDX Essentials: Basic Set Functions: The EXCEPT() Function
MDX Essentials: Basic Set Functions: The Intersect() Function
MDX Essentials: Basic Set Functions: The Union() Function
MDX Essentials: Basic Set Functions: The Order() Function
MDX Essentials - MDX Time Series Functions, Part III: The LastPeriods() and ParallelPeriod() Functions
MDX Time Series Functions, Part II: The OpeningPeriod () and ClosingPeriod() Functions
MDX Essentials - MDX Time Series Functions, Part I: PeriodsToDate() and Kindred Functions
MDX Essentials: MDX Member Functions: "Relative" Member Functions
MDX Member Functions: The Cousin () Function
MDX Essentials: Member Functions: More "Family" Functions
MDX Member Functions: The "Family" Functions
MDX Essentials: MDX Members: Introducing Members and Member
MDX Essentials : MDX Operators: The Basics
MDX Essentials: Structure of the MDX Data Model
MDX at First Glance: Introduction to SQL Server MDX Essentials








The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers