TopCount

Returns a set of n elements ordered from largest to smallest, optionally based on an evaluation.

This function ignores missing values.

Syntax

TopCount ( set , index [,numeric_value_expression ] )
ParameterDescription

set

The set from which the top n elements are selected.

index

The number of elements to include in the set (n).

numeric_value_expression

Optional. An expression further defining the selection criteria (see MDX Grammar Rules).

Example

The following query selects the five top-selling markets in terms of yearly Diet products sales, and displays the quarterly sales for each Diet product.

SELECT
 CrossJoin(
           [Product].[Diet].Children,
           [Year].Children
          ) 
ON COLUMNS,
 TopCount(
          [Market].Levels(0).Members,
          5, 
          [Product].[Diet]
         ) 
ON ROWS
FROM Sample.Basic
WHERE ([Scenario].[Actual], [Measures].[Sales])

This query returns the grid:

(axis)100-20100-20100-20100-20200-20200-20200-20200-20300-30300-30300-30300-30
(axis)Qtr1Qtr2Qtr3Qtr4Qtr1Qtr2Qtr3Qtr4Qtr1Qtr2Qtr3Qtr4
Illinois75595810508881391152015621402675755859894
California3674915064681658183319541706700802880673
Colorado7008028806735494654125391006921892991
Washington637712837704459498597514944799708927
Iowa162153121701291291291291658183319541706

See Also

  • BottomCount