Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

MDX FirstChild Function

by suresh

The MDX FirstChild function will return the First Child member belongs to the specified member. For example, If you know single customer name and if you want to find the Sales of a first customer then you can use this FirstChild function.

TIP: We can use MDX LastChild Function to find the Last Child Member.

MDX FirstChild Function Syntax

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

Member_Expression.FIRSTCHILD

Member_Expression: Any Multidimensional Expression that returns valid Member.

In this article we will show you, How to write FirstChild 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

MDX FIRSTCHILD FUNCTION

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

MDX FIRSTCHILD FUNCTION

MDX FirstChild Function Example

In this example we are going to find the First Children present in the France Country. It means first state present in the France country.

MDX CODE

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

OUTPUT

MDX FIRSTCHILD FUNCTION 1

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 write the first child member of the France from all the State-Provices present in the France country.

[Geography].[Geography].[Country].[France].FIRSTCHILD

MDX FirstChild Function Example 2

As we all know Paris is one of the state in France and our intention is to find the first state present in France then, we can use this FirstChild 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.

MDX CODE

SELECT 
 [Measures].[Reseller Sales Amount] ON COLUMNS,
 [Geography].[Geography].[State-Province].[Seine (Paris)].PARENT.FIRSTCHILD ON ROWS
FROM [Adventure Works];

OUTPUT
MDX FIRSTCHILD FUNCTION 2

ANALYSIS

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

[Measures].[Reseller Sales Amount] ON COLUMNS

From Below line of code,

[Geography].[Geography].[State-Province].[Seine (Paris)].PARENT.FIRSTCHILD

MDX will first implement the Parent function to find the parent member of a [Seine (Paris)], Which is France. Please refer MDX Parent Function for further understanding

Next, It will implement FirstChild function to find the first child member of the France Country, Which is Charente-Maritime. For Charente-Maritime State, there is no sales at all so, it is displaying Null results.

MDX FirstChild Function Alternative

In this example we are going to use the FirstChild function alternative to achieve the same result. Please refer MDX FirstSibling Function to understand the FirstSibling function.

MDX CODE

SELECT 
 [Measures].[Reseller Sales Amount] ON COLUMNS,
 [Geography].[Geography].[State-Province].[Seine (Paris)].FIRSTSIBLING ON ROWS
FROM [Adventure Works];

OUTPUT
MDX FIRSTCHILD FUNCTION 3

Thank you for Visiting Our Blog

Placed Under: MDX

Trending Posts

Data Profiling Task in SSIS

C strcmp Function

Error Handling in SSIS

Python Program to Perform Arithmetic Operations

Python GCD

XML Parser Transformation in Informatica

Increment and Decrement Operators in JavaScript

Python Program to check character is Lowercase or Uppercase

SQL RAND Function

Pin Report to Power BI Dashboard

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy