TOPN – first N rows from table (DAX – Power Pivot, Power BI)
This is about the TOPN DAX function, enabling us to see first (last) n rows from table (to do this in visualization, use this tutorial).
Let´s start with this table, containing total revenue for items.
To see first three items with highest revenue, the syntax is:
But what if we started with table containing not summarized values, like this?
Then we have to add the summarizing function and get three items from table provided by it:
-
Items with highest revenue (2) = topn(
3;
'original data';
'original data'[Goods];
"Total revenue";
'original data'[Revenue]));
[Total revenue];
desc)
This is about the TOPN DAX function, enabling us to see first (last) n rows from table (to do this in visualization, use this tutorial).
Let´s start with this table, containing total revenue for items.
To see first three items with highest revenue, the syntax is:
But what if we started with table containing not summarized values, like this?
Then we have to add the summarizing function and get three items from table provided by it:
-
Items with highest revenue (2) = topn(
3;
'original data';
'original data'[Goods];
"Total revenue";
'original data'[Revenue]));
[Total revenue];
desc)