Microsoft KB Archive/304118

= INF: How To Perform Time Series Calculations =

Article ID: 304118

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft SQL Server OLAP Services
 * Microsoft SQL Server 2000 Analysis Services

-



This article was previously published under Q304118



SUMMARY
Time series calculations are frequently required in business and financial reports. Multidimensional expressions (MDX) provide the following time oriented functions to perform time series calculations:
 * YTD
 * QTD
 * MTD
 * WTD
 * LastPeriods
 * PeriodsToDate

This article describes how to use the functions in the preceding list to provide year-to-date, quarter-to-date, month-to-date, and 12 month moving total calculations.



MORE INFORMATION
The logical parent dimension for a calculated member is Measures because it generally has the fewest members and is the dimension that is least likely to change. However, in situations where multiple time series calculations are required for each measure, creating a calculated measure for each time series and each measure increases the complexity of the cube, the chances of error, development costs, testing costs, and maintenance costs. One solution involves adding another dimension to the cube, with the sole purpose of providing the desired time series calculations.

For the purposes of illustration, you have been given the task of altering the Sales cube of the FoodMart 2000 sample. The change specification is that users must be able to display sums for all measures with the following time series:
 * Year To Date Sum
 * Quarter To Date Sum
 * Month To Date Sum
 * Moving Twelve Month Sum

To implement the desired changes, with minimal changes, use the following steps:  In Microsoft Access, open the FoodMart 2000.mdb file, and then create a new table named &quot;Periods&quot; with a single numeric column named &quot;Period&quot;. Set the Period column as a primary key.  Run the following update query: INSERT INTO PERIODS (PERIOD) VALUES (1);  Modify the structure of the Sales_Fact_1997, Sales_Fact_1998, and Sales_Fact_Dec_1998 tables, and add a numeric column named &quot;Period&quot; to each of these tables.  Run the following update queries: UPDATE SALES_FACT_1997 SET PERIOD=1 UPDATE SALES_FACT_1998 SET PERIOD=1 UPDATE SALES_FACT_DEC_1998 SET PERIOD=1  Close the FoodMart 2000 database file. Start Analysis Manager, select the FoodMart 2000 database, and then refresh the data source. Create a new dimension, named &quot;Periods&quot;, by using the Periods table as the data source. Save, and then process the new dimension.</li> Open the Sales cube for editing, and then add the Period dimension.</li> Create a new calculated member with the following properties: <ul> Member Name = &quot;Year To Date Sum&quot;</li> Parent Dimension = &quot;Periods&quot;</li> Value = SUM(YTD,[PERIODS].&[1])</li></ul> </li> Create a second calculated member with the following properties: <ul> Member Name = &quot;Quarter To Date Sum&quot;</li> Parent Dimension = &quot;Periods&quot;</li> Value = SUM(QTD,[PERIODS].&[1])</li></ul> </li> Create a third calculated member with the following properties: <ul> Member Name = &quot;Month To Date Sum&quot;</li> Parent Dimension = &quot;Periods&quot;</li> Value = SUM(MTD,[PERIODS].&[1])</li></ul> </li> Create a fourth calculated member with the following properties: <ul> Member Name = &quot;Moving Twelve Month Sum&quot;</li> <li>Parent Dimension = &quot;Periods&quot;</li> <li>Value = SUM(LastPeriods(12),[PERIODS].&[1])</li></ul> </li> <li>Save, and then process the cube.</li> <li>Click the Data tab of the Cube Editor, and then traverse the time dimension under each of the following: <ul> <li>Periods = 1</li> <li>Periods = Year To Date Sum</li> <li>Periods = Quarter To Date Sum</li> <li>Periods = Month To Date Sum</li> <li>Periods = Moving Twelve Month Sum</li></ul>

Note the differences in the data that display when different members of the Periods dimension are selected.</li></ol>

Additional query words: OLAP Time BIhowto

Keywords: kbinfo KB304118

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.