Skip to main content

Using Parent-Child Relationships

Using Parent-Child Relationships

The system provides the following MDX functions that directly use parent-child relationships:

  • CHILDREN returns the children, if any, of a given member. The returned value is a set of members, in the default order specified for the level. For example:

    SELECT MEASURES.[%COUNT] ON 0, homed.zip.[34577].CHILDREN ON 1 FROM demomdx
    
                                        %COUNT
    1 Cypress                               112
    2 Magnolia                              114
    3 Pine                                  121
    
    

    For another example:

    SELECT MEASURES.[%COUNT] ON 0, homed.pine.CHILDREN ON 1 FROM demomdx
    
                                        %COUNT
                                      No Result
    
    
  • PARENT returns the parent, if any, of a given member. For example:

    SELECT MEASURES.[%COUNT] ON 0, homed.city.[Elm Heights].PARENT ON 1 FROM demomdx
     
                                        %COUNT
    38928                                   228
    
    
  • FIRSTCHILD returns the first child, if any, of a given member. For example:

    SELECT MEASURES.[%COUNT] ON 0, homed.zip.[34577].FIRSTCHILD ON 1 FROM demomdx 
    
                                        %COUNT
    Cypress                                 112
    
    
  • LASTCHILD returns the last child, if any.

FeedbackOpens in a new tab