MDX in Analysis Services: Mastering Time: Introduction to Moving Averages

About the Series …

This article is a member of the series MDX in
Analysis Services
. The series is designed to provide hands-on
application of the fundamentals of MDX from the perspective of MS SQL Server
2000 Analysis Services
; our primary focus is the manipulation of
multidimensional data sources, using MDX expressions, in a variety of scenarios
designed to meet real-world business intelligence needs.

For more
information on the series, as well as the hardware / software requirements to
prepare for the tutorials we will undertake, please see the first lesson of
this series: MDX Concepts and Navigation.

Note: At
the time of writing, Service Pack 3 / 3a updates are assumed for MSSQL Server 2000, MSSQL
Server 2000 Analysis Services
, and the related Books Online
and Samples. Images are from a Windows 2003 Server
environment, upon which I have also implemented MS Office 2003, but the
steps performed in the articles, together with the views that result, will be
quite similar within any environment that supports MSSQL Server 2000 and
MSSQL Server 2000 Analysis Services ("Analysis Services" or "MSAS").
The same is generally true, except where differences are specifically noted,
when MS Office 2000 and above are used in the environment, with respect
to any MS Office components presented in a given article.

Overview

In
this article, we resume the focus of a group of articles that began with Mastering
Time: Change across Periods
. In that article, as well as its immediate successor, Mastering
Time: Period – to – Date Aggregations
,
we concentrated upon the Time dimension from the
perspective of our MDX queries. Our intent, in these and occasional subsequent
articles, is to explore ways to effectively report change over time, as
well as to accumulate those changes to present snapshots, trends and
other time-based metrics in a precise manner to meet typical business
requirements. As most of us realize, time is the most pervasive
dimension. A cube that has no time dimension is rare, indeed. Consequently,
this group of articles holds information that is of interest to virtually
anyone involved with MSAS cube design, development and use.

In
this article, we will examine "rolling average" aggregations,
a common business requirement. "Rolling," or "moving,"
averages
, involve a measure, the average under consideration, that is
aggregated over a progressively moving window of time periods. (While the
window typically involves time, the functions that define the "window"
involved here can certainly involve members of other dimensional levels).

Rolling averages are
popular in the business community because they have the effect of smoothing the
values of a quantity that fluctuates over time; these moving averages can be
especially useful in cases where the values to which they are applied are
subject to seasonal variations and other volatility factors.
They aid us in "normalizing," or "flattening," the presentation
of the metric for evaluation purposes. An example might be the S & P 500
Annual Yield 12-Month Rolling average, from a specific point in the past to
recent times, a representation of which is depicted in Illustration 1.



Illustration 1: S&P 500 Annual
Yield 12 Month Rolling Average %, 1947 to Present

As we
have stated, the value of the moving average, whether presented in chart,
tabular or other reports, often lies in its capacity to free us from some of the
distraction of fluctuations that are meaningless, or at least not completely
relevant, when it comes to trying to see long-term patterns in the analysis of
a quantity / measure. Because
they smooth a data series and make it easier to spot trends (something that is
especially helpful in volatile markets, and in many other environments, as
well), moving averages are one of the most popular and easy to use tools
available to the technical analyst. Moving averages also form the building
blocks for many other technical indicators and overlays.

In addition to being applied in the realm of stock prices, rolling
averages are used with many other metrics that change frequently. We might,
for instance, create a report to display weekly sales revenue over a three-year
window. We could, in this example, plot the figures for our organization’s
sales revenue for each of the weeks, along with another row (or line, in the
case of a chart) that displays a cumulative or a multi-week rolling average. A
rolling average is generated simply by calculating the average of the current
value, together with the specified number of previous values. The
individual values are, of course, typically identified by a time period.

MDX
affords us several approaches to generating rolling aggregates. We will explore
one of these in this article, and another in the next article of this series.
In both articles, we will overview the means of managing a rolling average
requirement, using MDX within MSAS to accomplish our ends. We will then
undertake a multi-step practice example that activates the underlying concepts,
discussing our objectives, as well as the results we obtain, with each step. We will:

  • Discuss
    considerations applicable to our approach, commenting generally upon the
    environment within which we will perform our practice exercises;

  • Examine a
    hypothetical business requirement, in which a group of information consumers
    have requested a particular moving average capability for analysis purposes;

  • Use the Sample
    Application to construct and test the MDX required to support a rolling average
    calculated member;

  • Create a
    calculated member in Analysis Manager to provide permanent rolling average
    support in the cube;

  • Verify
    accuracy of operation once again, from the Data view within the cube;

  • Demonstrate
    that the rolling average calculated measure behaves in a "contextually
    sensitive" way, within the context of the time dimension levels.
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.

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles