Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns the specified number of top-most rows in decreasing order of rank as specified by an expression.
Syntax
TopCount(<table expression>, <rank expression>, <count>)
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 value that is supplied by the <rank expression> argument determines the decreasing order of rank for the rows that are supplied in the <table expression> argument, and the number of top-most rows that is specified in the <count> argument is returned.
For example, assume that the following Sub-SELECT statement returns the table below:
(SELECT [Product Name], $Probability AS [Probability] FROM Predict([Products Purchases], INCLUDE_STATISTICS))
Product name | Probability |
---|---|
Apples |
0.4 |
Kiwi fruit |
0.1 |
Oranges |
0.5 |
Lemons |
0.2 |
The TopCount function can be used with the Sub-SELECT statement as follows:
TopCount((SELECT [Product Name], $Probability AS [Probability] FROM Predict([Products Purchases], INCLUDE_STATISTICS)), [Probability], 2)
This example yields the following results:
Product name | Probability |
---|---|
Oranges |
0.5 |
Apples |
0.4 |
See Also
Reference
Data Mining Extensions (DMX) Function Reference
Functions (DMX)
Mapping Functions to Query Types (DMX)