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 5

By William Pearson

The .FirstSibling Function

The .FirstSibling function is a bit more confusing than .FirstChild to some who are new to MDX, mainly in the way that it works for the first child of a given member-parent, but it may help again to relate the concept to a "family" scenario. As we discussed in the introductory section for this article, the .FirstSibling (as well as the .LastSibling) function operates within a "horizontal" scope for the hierarchy involved. It effectively "travels" within the same level of the hierarchy ("across" versus "up and down," as it does in the case of the .FirstChild and .LastChild functions.

Illustration 11 below depicts the relationships between the members and levels under consideration, as shown below:

Illustration 11: Revisiting the Time Dimension Hierarchy to Display .FirstSibling

The possibly confusing characteristic lies the fact that the first child (Q1 in the example illustrated above) also fills the role of first sibling - it is "first" within the horizontal level, and is the first sibling of any member residing at the same level. This is an ordering concept, and becomes straightforward once the meaning is clear. To amplify the concept with another illustration, let's examine the relationships when we consider the first sibling of Q3, as shown in Illustration 12 below.

Illustration 12: First Sibling for Q3 is Q1

We see in the illustration above that the first sibling of Q3 is Q1 - the first member in the level, plain and simple.


The .FirstSibling function is affixed to the right of the member, as in the following illustration:


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

{[Time].[Year].[1997].[Q2].FirstSibling} ON COLUMNS
FROM [Warehouse]
WHERE [Measures].[Units Ordered]

The dataset returned would appear as shown in Illustration 13 below:

Illustration 13: Result Dataset from Using the Example .FirstSibling 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