Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» Database News
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner


















FCC's Martin: Open Networks Becoming the Norm

Enterprise SaaS Buyers Want More Than Uptime

Cuban Waves Off SEC Allegations

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2 | Swynk







Related Articles
MDX Time Series Functions, Part II: The OpeningPeriod () and ClosingPeriod() Functions
MDX Essentials - MDX Time Series Functions, Part I: PeriodsToDate() and Kindred Functions
MDX Member Functions: The Cousin () Function
MDX Essentials: Structure of the MDX Data Model
MDX at First Glance: Introduction to SQL Server MDX Essentials

Senior Systems Engineer - UNIX (CO)
Next Step Systems
US-CO-Thornton

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

September 8, 2003

MDX Essentials - MDX Time Series Functions, Part III: The LastPeriods() and ParallelPeriod() Functions

By William Pearson

The ParallelPeriod() Function

The ParallelPeriod() function, according to the Analysis Services Books Online, "returns a member from a prior period in the same relative position as a specified member." This function would serve, as an illustration, to make it easy for us to navigate to "our current point in the year, last year," be the current point a month, quarter, or other period supported by our cube structure.

Similar to the case of the Cousin() function (see the seventh article in this series, Member Functions: The Cousin () Function), the ParallelPeriod() function operates upon the order and position of members within levels; ParallelPeriod() returns the child member with the same relative position under a given parent member as the specified child member under its own parent. The ParallelPeriod() function is more specifically adapted to time dimensions than Cousin(). It takes the ancestor of the specified member (in the typical case, a period), at a specified level, then looks at the specified sibling of the ancestor (who lags by a specified numeric expression) and returns the parallel period of the specified member from the descendants of that sibling.

When a level is not specified, the default member is Time.CurrentMember. When a level is specified, the default member is Dimension.CurrentMember, where Dimension is the dimension within which the specified level is a member. The default level is the parent of the specified member. The "lag distance" specified in the numeric expression defaults to "1," when it is not specified.

Discussion

The ParallelPeriod() function allows us to meet a business need that is common to virtually all industries. It allows us to return, for a given period, a value for its parallel in another time frame. ParallelPeriod() allows us to compare, for example, the sales over a given month with the sales that took place over the same month in the prior year, or a for a quarter this year over the same quarter last year. This might be particularly useful in a business whose revenues are highly seasonal (as in the case of a retail organization for whom Q4 - a large portion of which is Christmas shopping season - might make more sense to compare to Q4 of the prior year, rather than to Q3 of this year, when sales might have been (unsurprisingly) less.

As is the case with most of the time series functions, other, less direct approaches exist to meet business requirements of this nature. But ParallelPeriod() provides an easy, time-focused approach to this common need, as we will see in the sections that follow.

Syntax

Syntactically, the level, the sibling lag expression, and the specified member is placed within the parentheses to the right of ParallelPeriod(), as shown in the following illustration:

ParallelPeriod([<<Level>>[, <<Numeric Expression>>[, <<Member>>]]])

ParallelPeriod() takes the ancestor of <<Member>> at <<Level>> in the first argument, then returns the period parallel to <<Member>> under the ancestor's sibling that lags by <<Numeric Expression>>. The following simple example expression:

 ParallelPeriod ([Quarter], 2,[1998].[Q3].[9])

navigates to the sibling of the quarter-level ancestor of Quarter 3 (Q3 in the FoodMart sample cubes) in 1998, moves two quarters back (to Quarter 1), and then returns the cousin of September, (Month "9" in the FoodMart cubes) 1998. The month that is returned is therefore March (Month "3" in the FoodMart cubes).

Practice

Let's confirm our understanding of the function under consideration by using the ParallelPeriod() function in a way that we can get a feel for its operation.

We will create a simple query, which will again focus on Warehouse Cost.

1.  Type the following query into the Query pane:

-- MDX11-2:  Tutorial Query No. 2
SELECT
  
{[Measures].[Warehouse Cost]} ON COLUMNS,    
     { ParallelPeriod ([Quarter], 2,[1998].[Q3].[9])}ON ROWS
FROM Warehouse

Analysis Services fills the Results pane, presenting the dataset depicted in Illustration 3.


Illustration 3: Result Dataset - ParallelPeriod() Function

We see the total Warehouse Cost returned for Month 3 of Quarter 1 of 1998. As we discovered above, Quarter 1 is two quarters back from Quarter 3, which is the value of the numeric expression / index in the ParallelPeriod() function that we have used. Once we navigate to Quarter 1, the parallel month to Month 9 in Quarter 3 (the "last of the three months" in the quarter) is Month 3 (also the "last of the three months of the quarter").

We can prove the accuracy in the use of the ParallelPeriods() function by first reasoning that the "cousin" month for September (the third month in its quarter) in any given year is as follows for each of the other quarters of the year:

Quarter 1

March

Quarter 2

June

Quarter 4

December

Table 1: "Cousins" - The Third Month in Each Quarter

We realize that we wish to navigate to two quarters back in the timeline, so we know that we wish to focus on Quarter 1. Reasoning tells us that March, 1998, is therefore our targeted time dimension member.

Next, we can simply query the cube for the Warehouse Cost value for March 1998, by taking the following steps:

2.  Type the following query into the Query pane:

-- MDX11-2 Proof: Tutorial Query No. 2 Proof
SELECT    
  
{[Measures].[Warehouse Cost]} ON COLUMNS,    
    { [Time].[1998].[Q1].[3]} ON ROWS
FROM Warehouse

3.  Click the Run button on the toolbar atop the Sample Application, to execute the query.

Analysis Services does its work, resulting in the result dataset shown in Illustration 4.


Illustration 4: The Proof Query Result Dataset

The proof query delivers the results that we expected, based upon an alternative approach to the ParallelPeriods() function that we ran initially: The same results are generated from a more direct request for the value at the "parallel" month that the function should have, and apparently did, insert for us in the previous query.

In conclusion, we can easily see the utility of the LastPeriods() and ParallelPeriod () functions in providing us a relative route to data that is typically most useful within the context of time - utility that we can fine-tune with parameters that we can specify within arguments provided to the function.

Summary...

In this lesson, we concluded our examination of several useful members of the time series functions group, with two additional time-related functions, LastPeriods() and ParallelPeriod(). After discussing further the general business need to analyze data over time, we first overviewed the LastPeriods() and ParallelPeriod() functions. For each function, we then illustrated the syntax that is appropriate for its effective use. Finally, we tested our understanding of how to leverage the function by undertaking a relevant practice exercise, discussing the results we obtained and performing additional proof exercises to confirm their accuracy.

» See All Articles by Columnist William E. Pearson, III

Discuss this article in the MSSQL Server 2000 Analysis Services and MDX Topics Forum.

MDX Essentials Series
Part 71: Basic Set Functions: The BottomCount() Function, Part I
Part 70: Intrinsic Member Properties: The MEMBER_VALUE Property
Part 69: Intrinsic Member Properties: The MEMBER_UNIQUE_NAME Property
Part 68: Intrinsic Member Properties: The MEMBER_NAME Property
Part 67: Intrinsic Member Properties: The MEMBER_KEY Property
Part 66: Intrinsic Member Properties: The MEMBER_CAPTION Property
Part 65: Set Functions: The StripCalculatedMembers() Function
Part 64: Set Functions: The AddCalculatedMembers() Function
Part 63: MDX Numeric Functions: The Min() Function
Part 62: MDX Numeric Functions: The Max() Function
Part 61: Set Functions: The .AllMembers Function
Part 60: MDX Essentials: Set Functions: The MeasureGroupMeasures() Function
Part 59: String Functions: The .Properties Function, Part II
Part 58: String Functions: The .Properties Function
Part 57: Logical Functions: IsGeneration(): Conditional Logic within Filter Expressions
Part 56: MDX Scripting Statements: Introducing the Simple CASE Statement
Part 55: Logical Functions: IsGeneration(): Conditional Logic within Calculations
Part 54: Logical Functions: IsAncestor(): Conditional Logic within Filter Expressions
Part 53: MDX Clauses and Keywords: Use HAVING to Filter an Axis
Part 52: Logical Functions: IsAncestor(): Conditional Logic within Calculations
Part 51: Logical Functions: IsSibling(): Conditional Logic within Filter Expressions
Part 50: Logical Functions: IsSibling(): Conditional Logic within Calculations
Part 49: MDX Operators: The IsLeaf() Operator: Conditional Logic within Filter Expressions
Part 48: MDX Operators: The IsLeaf() Operator: Conditional Logic within Calculations
Part 47: MDX Numeric Functions: The .Ordinal Function
Part 46: Other MDX Entities: Perspectives
Part 45: MDX Operators: The IS Operator
Part 44: MDX Set Functions: The Distinct() Function
Part 43: MDX Set Functions: The ToggleDrillState() Function
Part 42: Set Functions: The DrillUpLevel() Function
Part 41: Set Functions: The DrillDownLevelTop() and DrillDownLevelBottom() Functions
Part 40: MDX Set Functions: DrillDownLevel()
Part 39: MDX Set Functions: The DRILLUPMEMBER() Function
Part 38: Set Functions: The DRILLDOWNMEMBERTOP() and DRILLDOWNMEMBERBOTTOM() Functions
Part 37: Set Functions: The DRILLDOWNMEMBER() Function
Part 36: Drilling Through with MDX: The DRILLTHROUGH Statement
Part 35: String Functions: The .UniqueName Function
Part 34: String Functions: The .Name Function
Part 33: String / Numeric Functions: The CoalesceEmpty() Function
Part 32: Basic Set Functions: The TopCount() Function, Part II
Part 31: Basic Set Functions: The TopCount() Function, Part I
Part 30: Enhancing CROSSJOIN() with Calculated Members
Part 29: Set and String Functions: The GENERATE() Function
Part 28: The CROSSJOIN() Function: Breaking Bottlenecks
Part 27: String / Numeric Functions: More on the IIF() Function
Part 26: String / Numeric Functions: Introducing the IIF() Function
Part 25: Logical Functions: The IsEmpty() Function
Part 24: Basic Set Functions: The EXTRACT() Function
Part 23: Numeric Functions: Introduction to the AVG() Function
Part 22: Basic Member Functions: The .Item() Function
Part 21: Basic Set Functions: Subset Functions: The Subset() Function
Part 20: Basic Set Functions: Subset Functions: The Tail() Function
Part 19: Basic Set Functions: Subset Functions: The Head() Function
Part 18: Basic Set Functions: The CrossJoin() Function
Part 17: Basic Numeric Functions: The Count() Function
Part 16: Basic Set Functions: The Filter() Function
Part 15: Basic Set Functions: The EXCEPT() Function
Part 14: Basic Set Functions: The Intersect() Function
Part 13: Basic Set Functions: The Union() Function
Part 12: Basic Set Functions: The Order() Function
Part 11: MDX Time Series Functions, Part III: The LastPeriods() and ParallelPeriod() Functions
Part 10: MDX Time Series Functions, Part II: The OpeningPeriod () and ClosingPeriod() Functions
Part 9: MDX Time Series Functions, Part I: PeriodsToDate() and Kindred Functions
Part 8: MDX Member Functions: "Relative" Member Functions
Part 7: MDX Member Functions: The Cousin () Function
Part 6: MDX Member Functions: More "Family" Functions
Part 5: MDX Member Functions: The "Family" Functions
Part 4: MDX Members: Introducing Members and Member
Part 3: MDX Operators: The Basics
Part 2: Structure of the MDX Data Model
Part 1: MDX at First Glance: Introduction to MDX Essentials

Go to page: Prev  1  2  3  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives







Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
Comparing Date Spans frankd 1 November 19th, 08:26 AM
Who can help me in relational algebraic expression and sql statment lonetlove 1 November 11th, 05:50 PM
SSIS Replace existing Records Problem g3lutz 1 November 11th, 10:25 AM
Backup SQL DB Mour 1 November 10th, 11:20 AM








internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers