TopPercent

Analysis Services Programming

Analysis Services Programming

TopPercent

The TopPercent function returns, in order of decreasing rank, the topmost rows of a table whose cumulative total is at least a specified percentage.

Syntax

TopPercent(<table expression>, <rank expression>, <percent>)

Applies to

An expression that returns a table, such as a <table column reference> or a function that returns a table.

Return Type

<table expression>

Remarks

The TopPercent function returns the topmost rows in decreasing order of rank based on the evaluated value of the <rank expression> argument for each row, such that the sum of the <rank expression> values is at least the given percentage specified by the <percent> argument. TopPercent returns the smallest number of elements possible while still meeting the specified percent value.

For example, assume that a table column named [Products] contains this table:

Product Name Unit Sales
Apples 30
Kiwi 10
Oranges 40
Lemons 20

TopPercent([Products], [Unit Sales], 60) function returns the following table:

Product Name Unit Sales
Oranges 40
Apples 30

Note that Apples was selected instead of Lemons.