Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Apr 22, 2003

MDX Essentials: Member Functions: More "Family" Functions - Page 7

By William Pearson

The .LastSibling Function

The .LastSibling function resembles the .FirstSibling function in its capacity to induce confusion to those new to MDX: the way that it behaves with the last child of a given member-parent is the interesting part, and, here again, it may help to relate to a "family" scenario. Like .FirstSibling, the .LastSibling function operates within a "horizontal" scope from the perspective of the hierarchy to which it belongs. It behavior mimics "travel" within the same level of the hierarchy ("across," again unlike the .FirstChild and .LastChild functions that we discussed in earlier parts of the lesson).

Illustration 17 below depicts the relationships under consideration, as shown below:

Illustration 17: .LastSibling in the Now-Familiar Time Dimension Hierarchy

The possibly confusing characteristic lies in the fact that the last child (Q4 in the example illustrated above) also fills the role of last sibling - it is "last" within the horizontal level, and is the last sibling of any member residing at the same level.

To amplify the concept with another illustration, let's examine the relationships when we consider the last sibling of Q2, as shown in Illustration 18 below.

Illustration 18: Last Sibling for Q2 is Q4

We see in the illustration above that the last sibling of Q2 is also Q4 - the last member in the level - and the same concepts as those we discussed for .FirstSibling earlier, just a "different direction."


The .LastSibling function, like the other functions we have examined in this lesson, is affixed to the right of the member, as in the following illustration:


A basic example of the .LastSibling function in action follows:

{[Time].[Year].[1997].[Q2].LastSibling} ON COLUMNS
FROM [Warehouse]
WHERE [Measures].[Warehouse Cost]

The result dataset returned would appear as shown in Illustration 19 below:

Illustration 19: Result Dataset from Using the Example .LastSibling Function

MS SQL Archives

Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM