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:

  • Items with highest revenue = TOPN(
       3; 
       ‘Table’; 
       ‘Table'[Total revenue]; 
       DESC) 
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;
       GROUPBY(
          ‘original data’;
          ‘original data'[Goods];
          “Total revenue”;
          SUMX(currentgroup();
          ‘original data'[Revenue]));
       [Total revenue];
       desc)

Leave a Reply

Your email address will not be published.

*

clear formPost comment