dcsimg

MDX Essentials: String / Numeric Functions: More on the IIF() Function - Page 4

January 3, 2005

We are placing the ORDER() function within the curly braces, and placing the entire FILTER() function, put into place in our last set of steps, into the ORDER() function, as the set, or first entry, which is followed by the "order by" numeric expression and "direction." (We are breaking the hierarchy in our descending sort, to make the Stores sort in accordance with the requirements of the information consumers), ([Measures].[SalesPerSqFt]), BDESC).

NOTE: For a detailed introduction to the ORDER() function, see my Database Journal article MDX Essentials: Basic Set Functions: The Order() Function.

Drawing close to the final version of our query, we have only to add formatting for our new calculated members, to make the data easier to understand for its eventual audience. We will accomplish this using the FORMAT_STRING, which we have exposed in several other articles of the series, as follows:

25.  In the line under the AS keyword, (the line that is enclosed in single apostrophes), within the first WITH MEMBER clause, where we define the first calculated member, ApproxSqFootage, that is:


'IIF([Store].CurrentMember.Level.Name = "Store Name",   
     Val([Store].CurrentMember.Properties("Store Sqft")), 0)'

insert a comma (",") at the end of the line.

26.  Insert the following in a new line, just beneath that in which we inserted the comma in the last step:

FORMAT_STRING = '#,##0'

27.  In the line under the AS keyword, (the line that is enclosed in single apostrophes), under the second MEMBER keyword , where we define the second calculated member, SalesPerSqFt, that is:

     '[Measures].[Store Invoice] / [Measures].[ApproxSqFootage]'

insert a comma (",") at the end of the line.

28.  Insert the following in a new line, just beneath that in which we inserted the comma in the last step:

FORMAT_STRING = '$#,##0.00'

Within the definitions of both calculated members, we are simply inserting FORMAT_STRING to assign user-friendly formats (round numbers, with a comma thousands separator, for square footage Store Area, and currency presentation for the Sales per Square Feet value).

Our modified query appears, with the altered sections in red rectangles, as shown in Illustration 7.


Illustration 7: Modified Query in Query Pane (with Changes in Rectangles)

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

The Results pane is populated with the DataSet depicted in Illustration 8.


Illustration 8: Results DataSet with ORDER() and Formatting Additions

A review of the DataSet at this stage reveals that we have succeeded in meeting the requirements expressed by the information consumers. While there are multiple ways to approach the delivery and presentation of a DataSet such as this, we have seen that, with only a few sequential steps, we can evolve a large data population into precisely the presentation that the intended audience requires. At the heart of our success in this example is the IIF() function, which, in conjunction with the VBA VAL() function and member properties, has facilitated the core data upon which the rest of the presentation depends.

30.  Select File -> Save to resave the file MDX27-4 in its designated location.

Summary ...

In this article, we continued our examination of the IIF() function, which we began in String / Numeric Functions: Introducing the IIF() Function. Our goal in this article was to focus on additional uses of the function in a more involved practice scenario, whereby we could explore new considerations (such as the use of IIF() with member properties), while reinforcing concepts that we exposed in our introductory article. To achieve our objectives, we undertook a multi-step practice example aimed at providing a requested presentation of a specified DataSet, to support of the illustrative business requirements of a hypothetical group of information consumers.

After gaining an understanding of the business needs of the intended audience, we created a core query. We then sequentially evolved the specified presentation of the requested DataSet, discussing, along the way, the functions and methods we used and the results that we obtained from each. At the core of our solution lay the IIF() function, used in conjunction with a member property, whose data type we converted to make it useful in the context of the business needs of the consumers. We then filtered, ordered, and formatted our presentation to further comply with the requirements outlined.

» 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