Export (0) Print
Expand All
Avg
IIf
Lag
Max
Min
Mtd
Qtd
Sum
Var
Wtd
Ytd
Expand Minimize

TopPercent (MDX)

Updated: 17 July 2006

Sorts a set in descending order, and returns a set of tuples with the highest values whose cumulative total is equal to or greater than a specified percentage.


TopPercent(Set_Expression, Percentage, Numeric_Expression) 

Set_Expression

A valid Multidimensional Expressions (MDX) expression that returns a set.

Percentage

A valid numeric expression that specifies the percentage of tuples to be returned.

Numeric_Expression

A valid numeric expression that is typically a Multidimensional Expressions (MDX) expression of cell coordinates that return a number.

The TopPercent function calculates the sum of the specified numeric expression evaluated over the specified set, sorting the set in descending order. The function then returns the elements with the highest values whose cumulative percentage of the total summed value is at least the specified percentage. This function returns the smallest subset of a set whose cumulative total is at least the specified percentage. The returned elements are ordered largest to smallest.

ms145498.note(en-US,SQL.90).gifImportant:
Like the BottomPercent function, the TopPercent function always breaks the hierarchy.

Example

The following example returns, for the Bike category, the smallest set of members of the City level in the Geography hierarchy in the Geography dimension for fiscal year 2003 whose cumulative total using the Reseller Sales Amount measure is at least the 15% of the cumulative total (beginning with the members of this set with the largest number of sales).

SELECT TopPercent
   ({[Geography].[Geography].[City].Members 
      *[Date].[Fiscal].[Fiscal Year].[FY 2003]}
   , 15
   , [Measures].[Reseller Sales Amount]
   ) ON 0,
   [Product].[Product Categories].Bikes ON 1
FROM [Adventure Works]

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.
  • Added updated examples.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft