In this article we will see how to display the TOP N and Others in Power BI, means to show the top n products and remaining products will be consolidated into single product and displayed as “Others”.
As you can see here we have a bar chart which displays total sales by products.

Lets take a look at table named financials that we are using as shown below.

Implementing TOP N and Others
As you can see, on X-axis we have taken products but now we have to show products and others on X-axis, for that we need to create a separate table which will have all unique products and others.
Lets create a table, go to Modeling tab and click on New table.

Now write a DAX formula as shown below.
UniqueProducts =
UNION (
 DISTINCT ( financials[Product] ),
 DATATABLE ( "Product", STRING, { { "Others" } } )
)



Name: provide the name for parameter.
Datatype: data type for values in parameter.
Minimum, and Maximum value: specify the minimum and maximum value for parameter.
Increment: this is how much the parameter will adjust when interacted with in a report.
Default: is a default value for parameter.
Add Slicer to this Page: when this is checked, It puts a slicer with your what-if parameter onto the current report page automatically.
After providing details click on Create Button.




Top N Total Sales =
VAR TOPN_Products =
 TOPN (
   'TOP N'[TOP N Value],
   ALLSELECTED ( UniqueProducts[Product] ),
   [Total Sales]
 )
VAR TOPN_Products_Sales =
 CALCULATE (
   [Total Sales],
   KEEPFILTERS ( TOPN_Products )
 )
VAR Other_Products_Sales =
 CALCULATE (         Â
   [Total Sales],
   ALLSELECTED ( UniqueProducts[Product])
 )
    - CALCULATE (            Â
     [Total Sales],
     TOPN_Products
    )
RETURN
 IF (                  Â
   SELECTEDVALUE ( UniqueProducts[Product] ) = "Others",
   Other_Products_Sales,
   TOPN_Products_Sales
 )


Lets create a measure as shown below.
Sorting Order = IF ( Â [Top N Total Sales] Â Â Â <> BLANK (), Â RANKX ( Â Â Â TOPN ( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'TOP N'[TOP N Value], Â Â Â Â Â ALLSELECTED ( UniqueProducts[Product]), Â Â Â Â Â [Total Sales] Â Â Â ), Â Â Â [Total Sales], Â Â Â Â Â Â , Â Â Â DESC, Â Â Â DENSE Â ) )






![]()
