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: Ancestors
Category: Navigation
Description: The Ancestors function returns a set of all ancestors at the specified level for the supplied member.
Syntax: ANCESTORS( «Member», «Level» )
ANCESTORS( «Member», «Distance» )
Technet Link: MDX Ancestors Function




This sample uses the distance (numeric expression) to return the parent (one level up) of November 2002.
 

SELECT
      {} ON COLUMNS,
      {ANCESTORS([Date].[Fiscal].[Month].[November 2002],1)} ON ROWS
FROM
      [Channel Sales]
 
 

 
This sample uses the distance (numeric expression) to return the set three levels up of November 2002…which in this case is Fiscal Year.
 

SELECT
      {} ON COLUMNS,
      {ANCESTORS([Date].[Fiscal].[Month].[November 2002],3)} ON ROWS
FROM
      [Channel Sales]
 
 

 
This query below returns a set that includes the November 2002 member itself, along with three levels above it.
 

SELECT
      {} ON COLUMNS,
      {ANCESTORS([Date].[Fiscal].[Month].[November 2002],0), ANCESTORS([Date].[Fiscal].[Month].[November 2002],1), ANCESTORS([Date].[Fiscal].[Month].[November 2002],2), ANCESTORS([Date].[Fiscal].[Month].[November 2002],3)} ON ROWS
FROM
      [Channel Sales]
 
 

 
The query below returns the Fiscal Year ancestor for the member November 2002.
 

SELECT
      {} ON COLUMNS,
      {ANCESTORS([Date].[Fiscal].[Month].[November 2002],[Date].[Fiscal].[Fiscal Year])} ON ROWS
FROM
      [Channel Sales]
 
 

 
 

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