MDX LastSibling Function

The MDX LastSibling function will return the Last Child member that belongs to the parent of a specified member. For example, If you know a single customer name and you want to find the Sales of the Last customer, then you can use this MDX Last Sibling function.

MDX LastSibling Function Syntax

The basic syntax of the MDX LastSibling in Multidimensional Expression is as shown below:

Member_Expression.LASTSIBLING

Member_Expression: Any Multidimensional Expression that returns valid Member.

For this LastSibling function in MDX query, We are going to use the below show data The following screenshot shows the Countries inside the Geography

LASTSIBLING FUNCTION

Following screenshot shows the [State – Provinces] inside the France Country

MDX LASTSIBLING FUNCTION

MDX LastSibling Function Example

If we know the Loiret is one of the states in France and we intend to find the Last state present in France then, we can use this LastSibling function. In this example, we are going to find the Last Children present in the State Province list and calculate the Reseller Sales Amount of that.

TIP: You can use MDX FirstSibling Function to find the First Sibling.

SELECT 
 [Measures].[Reseller Sales Amount] ON COLUMNS,
 [Geography].[Geography].[State-Province].[Loiret].LASTSIBLING ON ROWS
FROM [Adventure Works];
MDX LASTSIBLING FUNCTION 1

MDX LastSibling Function Example

In this example, we are going to find the Last Children present in the Countries list.

SELECT 
  [Measures].[Reseller Sales Amount] ON COLUMNS,
  [Geography].[Geography].[Country].[France].LASTSIBLING ON ROWS
FROM [Adventure Works];

MDX LASTSIBLING FUNCTION

In the above MDX Query, We used [Reseller Sales amount] on the columns

[Measures].[Reseller Sales Amount] ON COLUMNS

The below line of code will check for the France parent (Which is All member) and then finds the Last child member of the Country.

[Geography].[Geography].[Country].[France].LASTSIBLING

LastSibling Function Alternative

In this example, we are going to use the MDX LastSibling function alternative to achieve the same result. Please refer to the MDX Parent Function to understand the Parent function and refer to MDX LastChild function to understand the LastChild function.

SELECT 
 [Measures].[Reseller Sales Amount] ON COLUMNS,
 [Geography].[Geography].[Country].[France].PARENT.LASTCHILD ON ROWS
FROM [Adventure Works];

MDX LASTSIBLING FUNCTION 3

Categories MDX