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

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Apr 21, 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.

Syntax

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

<member>.FirstSibling

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

SELECT
{[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

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




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