TopSum

Returns the smallest possible subset of a set for which the total results of a numeric evaluation are at least a given sum. Elements of the result set are listed from largest to smallest.

Syntax

TopSum ( set, numeric_value_expression1, numeric_value_expression2 )
ParameterDescription

set

The set from which the highest-summing elements are selected.

numeric_value_expression1

The given sum (see MDX Grammar Rules).

numeric_value_expression2

The numeric evaluation (see MDX Grammar Rules).

Notes

Example

The following query selects the top-selling markets that collectively contribute 60,000 to the total yearly Diet products sales, and displays the quarterly sales for each Diet product.

SELECT
 CrossJoin(
          [Product].[Diet].Children,
          [Year].Children
          ) 
ON COLUMNS,
 TopSum(
       [Market].Levels(0).Members,
       60000, 
       [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
Florida620822843783548611657577332323260159
Oregon3893032773221006921892991263231197184