Mastering OLAP Reports: Parameterizing Number of “Top” Items with the MDX TopCount() Function, Part I

About the Series …

article is a member of the series MSSQL Server Reporting Services. The series is designed to
introduce MSSQL Server Reporting Services (“Reporting Services”),
presenting an overview of its features, with tips and techniques for real-world
use. For more information on the series in general, please see my initial Database Journal article, A New Paradigm for Enterprise Reporting. For the software components, samples and tools
needed to complete the hands-on portion of this article, see BlackBelt
Administration: Linked Reports in Report Manager
, another article within this

About the Mastering OLAP Reporting Articles …

One of
the first things that become clear to “early adopters” of Reporting Services
is that the “knowledgebase” for Analysis Services reporting with this
tool is, to say the least, sparse. As I stated in my article, Mastering
OLAP Reporting: Cascading Prompts
(where I treated the subject of cascading parameters
for Reporting Services 2000), the purpose of the Mastering OLAP Reporting subset of
my Reporting Services series is to focus on techniques for using Reporting Services
for OLAP reporting. In
many cases, which I try to outline in my articles at appropriate junctures, the
functionality of well-established, but expensive, solutions, such as Cognos
, can be met in most respects by Reporting Services – at a
tiny fraction of the cost.

vacuum of documentation in this arena, even taking into consideration the
release of several books surrounding Reporting Services 2005 in
recent months, continues to represent a serious “undersell” of Reporting
, from an OLAP reporting perspective. I hope to contribute
to making this arena more accessible for everyone, and to share my
implementation and conversion experiences as the series evolves. In the
meantime, we can rest assured that the OLAP potential in Reporting
will contribute significantly to the inevitable commoditization of
business intelligence, via the integrated Microsoft BI solution.

more information about the
Mastering OLAP
articles, see the section entitled
“About the Mastering OLAP Reporting Articles” in my article Ad Hoc
TopCount and BottomCount Parameters


recent articles within this series, we have focused upon various aspects of parameterization
within the Reporting Services environment. In some cases we have
supported parameterization from structures completely contained within Reporting
, and in others we have created parameter (predominantly
picklist) support from within other layers of the integrated Microsoft business
intelligence solution. As many of us are aware, enterprise reporting
applications typically allow for parameterization (via what are
sometimes known as “prompts” or “parameter prompts”) to enable information
consumers to quickly find the information they need from a report. These
parameters, whose values are physically passed to an axis specification or a
slicer in the dataset query, often act to put filters into place “on the fly;”
the “filters” are thus enacted when the consumer types or selects a value, or multiple
values, at run time.

Because they allow
information consumers to assume a role in guiding the delivery of information –
and add a “self-serve” component to the reporting experience – parameterization
in general is a popular topic in the forums and newsgroups of most enterprise
reporting applications. My first exposure to the concepts of parameterization
was in working with very early versions of Cognos Impromptu. Moreover, continued
application of those concepts over the succeeding years within Cognos, Crystal, Business Objects, MicroStrategy,
and several more specialized applications, has given me a great appreciation
for the opportunities that exist in the business environment for effective
parameterization. Whether the reports are to be printed, displayed on screen,
or any of the other options for production / deployment, it’s easy to see the
value that parameterization can add in making the selection and delivery of
enterprise data more focused and consumer-friendly.

I have extended parameterization concepts into many arenas, none have captured
my attention as much as their deployment within the integrated Analysis
/ Reporting Services pairing. These applications work
together to provide business intelligence in a way that is powerful and highly
flexible. Indeed, I often advise clients who are attempting to locate a
consultant to implement the integrated Microsoft BI solution (composed of MSSQL
, MSSQL Server Analysis Services, and Reporting Services)
to seek a “multidimensional architect” – a practitioner who has a good working
knowledge of each of the components, and who can determine where, among
three or more possible “logical layers,” to place which components, so
as to optimize the system as a whole.

NOTE: For details surrounding hands-on
approaches (as you will see, they are Legion) to the mechanics behind
supporting parameterization, (including the generation of picklists) in Reporting
, see these articles in my MSSQL
Server Reporting Services
series here at Database Journal:

Throughout various articles of this series, we have
generated simple lists to provide virtually all we need to support
parameterization within Reporting Services and other enterprise
reporting applications. In this article, we will perform a more detailed
examination of the mechanics behind parameterizing an MDX function
– or more precisely, for parameterizing the
variable argument within such a function. We will illustrate the process using
the popular TopCount() function, which we introduced
in Basic
Set Functions: The TopCount() Function, Part I
Set Functions: The TopCount() Function, Part II
(both members of my MDX Essentials series at Database
), but the same logic can be extrapolated to many other similar MDX
functions, as will become noticeable later in this article.

In this article, we will get hands-on exposure to parameterizing
an MDX function, TopCount(), within a preexisting sample OLAP report.
Beginning with the general concepts, we will continue into a practice session
where we set up a scenario, within which we work with a basic OLAP report, to
expose the steps involved. In
examining the rudiments of specific function parameterization within an OLAP
report containing a matrix data region, we will:

  • Open the
    sample Report Server project, AdventureWorks Sample Reports, and
    ascertain connectivity of its shared Analysis Services data source;
  • Create a clone
    of an existing sample report, containing a matrix data region, with
    which to perform our practice exercise;
  • Make structural
    modifications to the clone report, to prepare for our practice exercise session
    with parameters within a matrix data region;
  • Perform a
    brief overview of the MDX TopCount() function, which we will use to
    support the stated reporting needs of a hypothetical client;
  • Discuss the
    parameterization of MDX functions in general, and the TopCount()
    function specifically;
  • Add the
    required query parameters to support date and function parameterization;
  • Ensure the
    adequacy of automatically created datasets to support report
    and meet business requirements (in Part II of this article);
  • Add syntax to
    the TimeMonth dataset query to enforce cascading (in Part II
    of this article);
  • Leverage the
    MDX TopCount() function, containing the “number of counts” placeholder(in Part II of this article);
  • Discuss the
    interaction of the various components in supporting the runtime parameters
    that the end consumer sees (throughout Part I and Part II of this article);
  • Discuss the
    results obtained with the development techniques that we exploit (throughout Part I and Part II of this article).
William Pearson
William Pearson
Bill has been working with computers since before becoming a "big eight" CPA, after which he carried his growing information systems knowledge into management accounting, internal auditing, and various capacities of controllership. Bill entered the world of databases and financial systems when he became a consultant for CODA-Financials, a U.K. - based software company that hired only CPA's as application consultants to implement and maintain its integrated financial database - one of the most conceptually powerful, even in his current assessment, to have emerged. At CODA Bill deployed financial databases and business intelligence systems for many global clients. Working with SQL Server, Oracle, Sybase and Informix, and focusing on MSSQL Server, Bill created Island Technologies Inc. in 1997, and has developed a large and diverse customer base over the years since. Bill's background as a CPA, Internal Auditor and Management Accountant enable him to provide value to clients as a liaison between Accounting / Finance and Information Services. Moreover, as a Certified Information Technology Professional (CITP) - a Certified Public Accountant recognized for his or her unique ability to provide business insight by leveraging knowledge of information relationships and supporting technologies - Bill offers his clients the CPA's perspective and ability to understand the complicated business implications and risks associated with technology. From this perspective, he helps them to effectively manage information while ensuring the data's reliability, security, accessibility and relevance. Bill has implemented enterprise business intelligence systems over the years for many Fortune 500 companies, focusing his practice (since the advent of MSSQL Server 2000) upon the integrated Microsoft business intelligence solution. He leverages his years of experience with other enterprise OLAP and reporting applications (Cognos, Business Objects, Crystal, and others) in regular conversions of these once-dominant applications to the Microsoft BI stack. Bill believes it is easier to teach technical skills to people with non-technical training than vice-versa, and he constantly seeks ways to graft new technology into the Accounting and Finance arenas. Bill was awarded Microsoft SQL Server MVP in 2009. Hobbies include advanced literature studies and occasional lectures, with recent concentration upon the works of William Faulkner, Henry James, Marcel Proust, James Joyce, Honoré de Balzac, and Charles Dickens. Other long-time interests have included the exploration of generative music sourced from database architecture.

Latest Articles