TOPN DAX Function in Power BI

The TOPN DAX function returns a table with the top N rows of the specified Table or an empty table if N_Value is 0 (zero) or less.

DAX Syntax TOPN(N_Value, Table, OrderBy_Expression, [Order[, OrderBy_Expression, [Order]]…])

Example: Let’s we have a Students table, as shown in the image below:

TOPN dax function in Power BI

By using the following DAX expression, we will create a calculated table, consists of the top three rows from the Students table.

DAX

TOPN Table = TOPN(3, Students)

The output of the above dax code is shown below:

TOPN dax function in Power BI