Implementing top N analysis
People and companies love top N lists. There are whole websites dedicated to The top 10 foods that celebrity data analysts like to eat and Top 25 ways to make your Power BI data model faster. Not really, but I would definitely sign up for the first one!
Top N lists can provide useful information for organizations. Data consumers like to see what the company's top-selling products are. What is the most popular color widget? How do I compare my top 10 product's revenue against the rest?
There are actually two different problems here. One is to generate a ranking function and display it, and the other is to create a top N table to use a filter in a measure.
Ranking function
You can create a rank and ordered list by using the RANKX
function. This is another one of those X
functions that aggregate over a table. It will produce a numerical ranking of a category by an expression:
RANKX(<table>, <expression>[, <value>...