In Multidimensional Expression, FirstSibling function will return the First Child member that belongs to the parent of a specified member. For example, If you know single customer name and you want to find the Sales of a first customer then you can use this FirstSibling function.
MDX FirstSibling Function Syntax
The basic syntax of the MDX FirstSibling is:
Member_Expression.FIRSTSIBLING
Member_Expression: Any Multidimensional Expression that returns valid Member.
In this article we will show you, How to write FirstSibling function in MDX query with examples. For this, We are going to use the below show data
Following screenshot shows the Countries inside the Geography
Following screenshot shows the [State – Provinces] inside the France Country
OUTPUT
Analysis:
In the above MDX Query, We used [Reseller Sales amount] on the columns
[Measures].[Reseller Sales Amount] ON COLUMNS
Below line of code will check for the France parent (Which is All member) and then finds the first child member of the Country.
[Geography].[Geography].[Country].[France].FIRSTSIBLING
MDX FirstSibling Function Example 2
If we know the Loiret is one of the state in France and our intention is to find the first state present in France then, we can use this FirstSibling function. In this example we are going to find the First Children present in the State Province list and calculate the Reseller Sales Amount of that.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[State-Province].[Loiret].FIRSTSIBLING ON ROWS
FROM [Adventure Works];
OUTPUT
Analysis:
In the above MDX Query, We used [Reseller Sales amount] on the columns
[Measures].[Reseller Sales Amount] ON COLUMNS
Below line of code will check for the Loiret parent (Which is France) and then finds the first child member of the France Country.
[Geography].[Geography].[Country].[France].FIRSTSIBLING
For Charente-Maritime State, there is no sales at all so, it is displaying Null results.
MDX FirstSibling Function Alternative
In this example we are going to use the FirstSibling function alternative to achieve the same result. Please refer MDX Parent Function to understand the Parent function and refer MDX FirstChild function to understand the FirstChild function.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[State-Province].[Loiret].PARENT.FIRSTCHILD ON ROWS
FROM [Adventure Works];
OUTPUT
MDX FirstSibling Function Syntax
The basic syntax of the MDX FirstSibling is:
Member_Expression.FIRSTSIBLING
Member_Expression: Any Multidimensional Expression that returns valid Member.
In this article we will show you, How to write FirstSibling function in MDX query with examples. For this, We are going to use the below show data
Following screenshot shows the Countries inside the Geography
Following screenshot shows the [State – Provinces] inside the France Country
MDX FirstSibling Function Example
In this example we are going to find the First Children present in the Countries list.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[Country].[France].FIRSTSIBLING ON ROWS
FROM [Adventure Works];
In this example we are going to find the First Children present in the Countries list.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[Country].[France].FIRSTSIBLING ON ROWS
FROM [Adventure Works];
OUTPUT
Analysis:
In the above MDX Query, We used [Reseller Sales amount] on the columns
[Measures].[Reseller Sales Amount] ON COLUMNS
Below line of code will check for the France parent (Which is All member) and then finds the first child member of the Country.
[Geography].[Geography].[Country].[France].FIRSTSIBLING
MDX FirstSibling Function Example 2
If we know the Loiret is one of the state in France and our intention is to find the first state present in France then, we can use this FirstSibling function. In this example we are going to find the First Children present in the State Province list and calculate the Reseller Sales Amount of that.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[State-Province].[Loiret].FIRSTSIBLING ON ROWS
FROM [Adventure Works];
OUTPUT
Analysis:
In the above MDX Query, We used [Reseller Sales amount] on the columns
[Measures].[Reseller Sales Amount] ON COLUMNS
Below line of code will check for the Loiret parent (Which is France) and then finds the first child member of the France Country.
[Geography].[Geography].[Country].[France].FIRSTSIBLING
For Charente-Maritime State, there is no sales at all so, it is displaying Null results.
MDX FirstSibling Function Alternative
In this example we are going to use the FirstSibling function alternative to achieve the same result. Please refer MDX Parent Function to understand the Parent function and refer MDX FirstChild function to understand the FirstChild function.
CODE
SELECT
[Measures].[Reseller Sales Amount] ON COLUMNS,
[Geography].[Geography].[State-Province].[Loiret].PARENT.FIRSTCHILD ON ROWS
FROM [Adventure Works];
OUTPUT