Time and Accumulation
As we discussed in our
last article, many business requirements revolve around the performance of analysis within the
context of time. In performing virtually any type of data analysis with
a cube, we are typically confronted with the need to do so with reference to time. In our last session, we
discussed, and worked through a hands-on example surrounding, meeting a need to
compare a measure or measures across months, quarters, or years. In addition to
analyzing growth over periods in time, a need upon which we focused in Change across Periods, another need, familiar to most
of us who have worked within accounting and finance circles, is the requirement
to present year-to-date totals, averages or other accumulations.
Because of pervasive
business needs to analyze data within the context of time, MDX provides a
specialized group of time series functions to meet these and many other needs. The
article MDX
Time Series Functions, Part I: PeriodsToDate() and Kindred Functions, in my Database Journal MDX Essentials series,
focuses in detail on the syntax and operation of the PeriodsToDate() function, together
with the specialized "shortcut" functions that are based upon it,
including the YTD(), QTD(), MTD(), and WTD() functions.
If you haven't read MDX Time Series
Functions, Part I,
it might act as a great syntopic reinforcement, either before or after
completing this lesson, as examining concepts from multiple perspectives often
tends to activate them more effectively. Following this approach, together with
PhotoReading and other tools, helps me to master new material quickly. I
heartily suggest it to anyone who shares my opinion that time (in general) is
the only thing that is really important.
As we mentioned in our
last article, MSAS provides excellent tools for presenting data within the
relative time concepts so valued by information consumers, and the same applies
within our examination of period-to-date concepts. The implements MSAS
offers include:
-
Time
dimension(s);
-
Alternate
hierarchy capabilities;
-
MDX
time-series functions;
-
Calculated members.
The PeriodsToDate() function, according
to the Analysis Services Books Online,
"returns a set of periods (members) from a specified level, starting with
the first period and ending with a specified member." Within the scope of
a level that is specified
within the function, the function returns a set of periods that exist on the
same level as the member that is also specified in the expression. In other
words, it returns the number of periods within the specified level, up to and
including the specified member. When no level or member is specified, the value
of the member is Time.CurrentMember
(a concept we have discussed earlier in our series), with the Level
value being the parent level of Time.CurrentMember.
As we attempted to do in Mastering Time: Change across Periods, this article will treat the practical presentation of data with time
as a consideration. While the specialized time-series functions are called
upon, we will look at a combination of MDX elements to bring about the results
we are called upon to obtain.