Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Creating a Top N and Others Table from related table (using Rankx)

Hello,

 

I'm trying to create a table showing say Top 5 Sales by Products and the balance in others. My tables are as follows:

 

SalesTable  
CustomerProductAmount
AAAA100
BBBB50
CCCC10
DAAA100

 

ProductsTable 
ProductDescription
AAA 
BBB 
CCC 

 

Intended output...

Ranked Product Table 
ProductSales
AAA200
BBB50
Others10



I have tried the solution here, but came across errors.
I am able to rank the products with the following formula:
Product Rank = RANKX(ALL('ProductsTable'[product]),SUMX(RELATEDTABLE('SalesTable'),'SalesTable'[Amount]))

I am unable to create the next formula:
Top 5 products = IF([Product Rank]<6,'ProductsTable'[product],"others") where i am unable to reference the column, 'ProductsTable'[product], either directly or using RELATED.

Does anyone know how to solve this?

2 REPLIES 2
amitchandak
Super User
Super User

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can have a look at the blog.

 

https://blog.gbrueckl.at/2019/05/power-bi-dynamic-topn-others-with-drill-down/

 

https://www.youtube.com/watch?v=UAnylK9bm1I

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.