TOPN DAX Function (Table manipulation)

Zwraca daną liczbę górnych wierszy, zgodnie z określonym wyrażeniem.


TOPN ( <N_Value>, <Tabela> [, <OrderBy_Expression> [, [<Order>] [, <OrderBy_Expression> [, [<Order>] [, … ] ] ] ] ] )
Parameter Attributes Description

Liczba wierszy, które zostaną zwrócone.


Wyrażenie definiujące tabelę, z której będą zwracane wiersze.

Row Context

Wyrażenie, które będzie używane do sortowania tabeli.

Order Optional

Kolejność, która ma zostać zastosowana. 0/FALSE/DESC — malejąca; 1/TRUE/ASC — rosnąca.

Return values

Table An entire table or a table with one or more columns.

A table with the top N_value rows of Table or an empty table if N_value is 0 (zero).


If there is a tie, in OrderBy_Expression values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows.

If N_Value is 0 (zero) then TOPN returns an empty table.

TOPN does not guarantee any sort order for the results.

Related functions

Other related functions are:

Last update: Dec 14, 2019   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

MSDN documentation:

DAX Conventions
Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.


Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.


This function is deprecated. Jump to the Alternatives section to see the function to use.


This parameter is deprecated and its use is not recommended.


Want to improve the content of TOPN? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.