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 Aug 1, 2005

MDX Essentials: String Functions: The .Name Function - Page 3

By William Pearson

And so, we see the .Name function at work with a couple of different relative members, .CurrentMember and .Parent. We note that our handiwork brings about results similar to those we obtained in our first example, hierarchically leveraging the effects of combining .Name with other functions.

Let's see a final example wherein we set the stage for our next article, creating one half of a dataset that we will complete upon introduction of an additional function. We will prepare the core query that we can use to support a picklist in a reporting application, specifically where we seek to parameterize a report whose data source is an OLAP cube. This portion of the query will center on the .Name function. In our next article, where we introduce the .UniqueName function, we will re-introduce the query with further addition of .UniqueName to show a great way to handle the support of picklist parameterization for a reporting application from the Analysis Services level.

A common requirement in the reporting environment is parameterization using picklists. A specific picklist format that I like to provide my clients involves a hierarchized selection, such that they can select various levels of a dimension in the picklist and obtain "rolled up" aggregation as well as bottom level values, simply by choosing from an intuitive list of selections.

Our example will involve only the list of names that appears to the information consumer in the picklist selector of the report. The unseen portion of the support dataset, the qualified MDX name that must be passed to the query to complete the query and render the appropriately filtered presentation, will be constructed in our next article via the .UniqueName function. Our query at present will also introduce a VBA function, Space() to perform the indentation effects with which we wish to endow the selection list, to make it even more user-friendly in the ultimate report.

Let's say that we have been called upon by the information consumers to provide such a picklist: They want the users of a new report to be able, at runtime, to select any member or level of the Warehouse hierarchy to generate a report that is specified within the context selected. The information consumer group would like users to be able to run various reports with corresponding values / totals based upon the selection of a given Warehouse, a Warehouse City, a Warehouse State Province, a Warehouse Country, or all Warehouses in total. After confirming our understanding of the desired format of the selection list, we draft the tentative presentation sample in a way that appears as partially shown below:

All Warehouses (All Level)

          Canada (Warehouse Country)

                     BC (Warehouse State Province)

                             Vancouver (Warehouse City)

                                      Bellmont Distributing (Warehouse)

The information consumers confirm our understanding of the requirements, allowing us to begin taking the following actions to meet their specifications:

12.  Select File --> New from the main menu to begin a new MDX query, leaving DB and Cube settings as before.

13.  Type the following query onto the query pane:

-- MDX034-03  Using .NAME to create a hierarchical List of the Warehouse --
-- Dimension for use in a Report Picklist
   [Measures].[Warehouse Hierarchical Picklist]
   'Space([Warehouse].Currentmember.Level.Ordinal * 6) + 
    {[Measures].[Warehouse Hierarchical Picklist]} ON COLUMNS,
    {[Warehouse].Members} ON ROWS

The Query pane appears as depicted in Illustration 4, with the new query in place.

Illustration 4: The Picklist Selection List Query

14.  Execute the query by clicking the Run Query button in the toolbar.

The Results pane is populated, and the dataset partially shown in Illustration 5 appears.

Illustration 5: Results Dataset (Partial View) – The Hierarchical List Emerges ...

The MDX query returns, via our calculated member, a display name that we can use to populate a picklist within the reporting layer of an integrated BI solution. The picklist will provide information consumers with a selection as a part of a prompted parameterization scenario within a report. The Space() VBA function is used together with the level ordinal property of the current member to generate a "space size." We then multiply that size value by six (6). The resulting indentation is then concatenated with the name of the current member ([Warehouse].CurrentMember.Name).

Our objective here is cosmetic – we are simply making the geographical levels of the Warehouse dimension appear more intuitively hierarchical for the consumers, by "indenting" each of the various levels of the Warehouse dimension in accordance with its level in the hierarchy. Note that there is more to supporting the ultimate picklist, including a "parallel" qualified name for each name in the selection list we have constructed. We will begin our next article's practice session, which focuses on the .UniqueName function, in the construction of the "other half" of the picklist, to provide the necessary qualified name to allow the MDX in the report dataset query to filter in accordance with the selected criteria.

NOTE: For a detailed, hands-on setup procedure of hierarchical picklist support within an Analysis Services cube, see my Database Journal MDX in Analysis Services article Create a Cube-Based Hierarchical Picklist.

15.  Save the file as MDX034-3.

16.  Close the MDX Sample Application, as desired.

Summary ...

In this article, we explored the MDX .Name function, which can be called upon in activities that range from generating simple lists to supporting sophisticated presentations. We introduced the function, commenting upon its operation and touching upon the creative effects we can deliver using the function.

We examined the syntax involved with the function, and then undertook illustrative practice examples of business uses for .Name, generating queries that capitalized on its primary features. Our exercises concluded with an example that looked forward to our next article, where we rejoin the exercise and employ the .UniqueName function to deliver intended results. Finally, 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.

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