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

August 1, 2005

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
WITH
MEMBER
   [Measures].[Warehouse Hierarchical Picklist]
AS
   'Space([Warehouse].Currentmember.Level.Ordinal * 6) + 
    [Warehouse].CurrentMember.Name'
SELECT 
    {[Measures].[Warehouse Hierarchical Picklist]} ON COLUMNS,
    {[Warehouse].Members} ON ROWS
FROM
    [WAREHOUSE]

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.

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