Home      Functions     Common Solutions      Contact     






MDX Functions:
 
MDX Functions

 
Common Solutions

Common Solutions
 
Resource Links

MDX Books
MDX Related Software
MDX Related Blogs
 
Other Links

Contact Us
 
Microsoft SQL Server Analysis Services Function Page
Function Name: Ancestor
Category: Navigation
Description: The Ancestor function returns a member at the specified level for for the supplied member.
Syntax: ANCESTOR( «Member», «Level» )
ANCESTOR( «Member», «Distance» )
Technet Link: MDX Ancestor Function




The query below returns the Clothing member which is an ancestor at the Product Category level for the member Half-Finger Gloves, S.
 

SELECT
      {} ON COLUMNS,
      {ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S], [Product].[Product Categories].Category)} ON ROWS
FROM
      [Channel Sales]
 
 

 
This query uses the distance (numeric expression) to return the parent (one level up) of Half-Finger Gloves, S.
 

SELECT
      {} ON COLUMNS,
      {ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S], 1)} ON ROWS
FROM
      [Channel Sales]
 
 

 
The query below uses the distance (numeric expression) to return the set two levels up from the Product member Half-Finger Gloves, S..
 

SELECT
      {} ON COLUMNS,
      {ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S],2)} ON ROWS
FROM
      [Channel Sales]
 
 

 
This query below returns members at the Category, SubCategory and Product levels for the supplied member.
 

SELECT
      {} ON COLUMNS,
      {ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S],2), ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S],1), ANCESTOR([Product].[Product Categories].[Product].[Half-Finger Gloves, S],0)} ON ROWS
FROM
      [Channel Sales]
 
 

 
 

 
Copyright 2008 by MDXpert.com.
 
Terms of Use                              Privacy Statement
 
Site Powered By - WinHost.Com