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: Rank
Category: Statistical
Description: The Rank function returns the one-based rank of the supplied tuple in the supplied set.
Syntax: RANK( «Tuple», «Set» )
Technet Link: MDX Rank Function




The query below returns the Rank of each Month member within the FY 2003 member without regard to a numeric expression.
 
WITH
      MEMBER [Measures].[DateRank] AS
      RANK([Date].[Fiscal].CurrentMember, DESCENDANTS([Date].[Fiscal].[FY 2003], [Date].[Fiscal].[Month]))
SELECT
      {[Measures].[DateRank]} ON COLUMNS,
      DESCENDANTS([Date].[Fiscal].[FY 2003], [Date].[Fiscal].[Month]) ON ROWS
FROM
      [Adventure Works]
 
 

 
The following query returns the Rank of each Month member within the FY 2003 member according to the measure Order Count.
 
WITH
      MEMBER [Measures].[DateRank] AS
      RANK([Date].[Fiscal].CurrentMember, DESCENDANTS([Date].[Fiscal].[FY 2003], [Date].[Fiscal].[Month]), [Measures].[Order Count])
SELECT
      {[Measures].[DateRank], [Measures].[Order Count]} ON COLUMNS,
      DESCENDANTS([Date].[Fiscal].[FY 2003], [Date].[Fiscal].[Month]) ON ROWS
FROM
      [Adventure Works]
 
 

 
The query below returns the Rank of each Country member in the Customer Geography hierarchy of the Customer dimension based on the Customer Count measure.
 
WITH
      MEMBER [Measures].[CustRank] AS
      RANK([Customer].[Customer Geography].CurrentMember, ORDER([Customer].[Customer Geography].[Country].Members, [Measures].[Customer Count], BDESC))
SELECT
      {[Measures].[CustRank], [Measures].[Customer Count]} ON COLUMNS,
      ORDER({[Customer].[Customer Geography].[Country].Members}, [Measures].[CustRank]) ON ROWS
FROM
      [Adventure Works]
 
 

 
 

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