dcsimg

MDX Essentials: Basic Set Functions: The TopCount() Function, Part II

June 6, 2005

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, as well as the software and systems requirements for getting the most out of the lessons included, please see my first article, MDX at First Glance: Introduction to MDX Essentials.

Note: Current updates are assumed for MSSQL Server, MSSQL Server Analysis Services, and the related Books Online and Samples.

Overview

In this article, we will continue the examination of the TopCount() function that we began in the previous article of the MDX Essentials series, Basic Set Functions: The TopCount() Function, Part I. Before getting "hands-on" with TopCount() in our last session, we introduced the function, stating that its highest value lies in the fact that we can use it as a means for isolating best performers from among potentially large populations of fellow members. We emphasized that this ranking capability is a critical need in many data analysis and decision support scenarios, where we often seek to report upon best performers for various reasons.

We learned that TopCount() facilitates this ranking capability, allowing us to sort on the numeric value expression upon which we wish to focus our analysis. We can direct the function to retrieve the exact number of "top" members we wish to isolate (say, the "top ten," or the "top twenty"), for a "custom-fit" approach, that precisely matches the analysis needs of our own environments.

In this article, we will extend our examination of the TopCount() function to include somewhat more sophisticated uses. We will dive right into a couple of practical scenarios, where we will further evolve our understanding of the operation of TopCount() through:

  • Defining illustrative business needs as posed to us by hypothetical groups of information consumers;
  • Discuss the needs from the perspective of MDX in general, and the TopCount() function in particular;
  • Construct queries to meet the expressed requirements using combinations of TopCount() and other MDX functions we have explored in articles of the series;
  • Discuss the syntax contained within the solutions we construct for the information consumers;
  • Briefly discuss the results datasets we obtain in executing the MDX queries we construct.

To review an introduction to the TopCount() function before beginning this article, together with examples of its use in basic scenarios, see my article Basic Set Functions: The TopCount() Function, Part I, a member of the MDX Essentials series at Database Journal.

Combining TopCount() with other MDX Functions to Add Sophistication

In our introductory article, we examined the syntax for the TopCount() function, and then looked at its behavior, based upon arguments we provided to achieve our ends. We learned that TopCount() sorts a set we specify by another expression we provide within the function, thus breaking the natural hierarchy of the set. In returning "a specified number of items from the topmost members of a specified set, optionally ordering the set first," we noted, the TopCount() function is an excellent example of the potential power of MDX.

We learned that we specify three parameters to TopCount(), a set, a count, and a measure, and that we can return the number of top performers (or "top anything," in effect), based upon our input, using the syntax shown in the following string:

TopCount(<< Set >>, << Count >> [,<< Numeric Expression >>])

Sophisticated results can be generated using TopCount() when we supply well-considered parameters to the <<Set>> and <<Numeric Expression>> arguments, as we shall see in the practice exercises that follow.








The Network for Technology Professionals

Search:

About Internet.com

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