TopN
Table
Adds calculated columns to table expression.
Parameters
n_value -> Number
Number or DAX expression that returns a number.
table -> Table
Table from which rows need to be pulled.
order_by_expression -> Any
DAX expression that is used to sort the table.
order -> Number
Defines sort order. 0 (default) for descending order and 1 for ascending order.
Returns
Type: Table
Table with n_value rows.
Details
- Rows returned by TopN function are not sorted in any order.
- TopN returns empty table if n_value is less than or equal to zero.
- If there is a tie at Nth rows, then all rows under tie are returned. This can lead to return of more than n_value rows.
Examples
The following formula returns table with top 5 employees with highest current salary followed by checking earlier date of joining if there are ties
= TOPN( 5 Employee, "CurrentSalaray", 0 "DateOfJoining", 1 )