MDX Parent Function

The MDX Parent function will return the associate parent member of the specified member. For instance, If you are an Amazon developer and If one of your customer is looking for iPod in Amazon.com. As a developer, you have to display all the Apple products at the bottom of the page so that the user can browse other products, and sometimes he may buy? In these situations, you can use the MDX parent function to find iPod parents by writing something like [Product].[Apple].[iPod].PARENT

MDX Parent Function Example

We have one customer in the Customer Geography Hierarchy called [Antonio G. Patterson]. In this example, we are going to find the [Internet Sales amount] of all the customers who are living in the same postal code as [Antonio G. Patterson].

SELECT [Measures].[Internet Sales Amount] ON COLUMNS, 

 [Customer].[Customer Geography].[Customer].[Antonio G. Patterson].PARENT ON ROWS 

FROM [Adventure Works]
MDX PARENT FUNCTION

The below statement will place the [Internet Sales Amount] in the columns region.

[Measures].[Internet Sales Amount] ON COLUMNS

The below MDX statement will find the parent (One level above) of [Antonio G. Patterson]. As per Customer Geography, Hierarchy Postal Code is the level above the Customers, and [Antonio G. Patterson] lives in 2450 Postal Code.

[Customer].[Customer Geography].[Customer].[Antonio G. Patterson].PARENT

So, below MDX query will calculate the total [Internet Sales Amount] against the Postal Code 2450.

SELECT [Measures].[Internet Sales Amount] ON COLUMNS, 
 
[Customer].[Customer Geography].[Customer].[Antonio G. Patterson].PARENT ON ROWS 

FROM [Adventure Works]