RANKX Vs TOPN what is the difference?


Hi Sam trying to get my head around this.
Even after doing many YouTube Videos around TOPN and RANKX I still cannot get my head around this function.

RANKX - I get this, RANKX (row level data it’s being RANKED, similar to Excel RANK. This is below what I have.


TOPN (this is really confusing)
As you will see my TOPN is different to my RANKX number.
From a business perspective more so, how and why would i need to use TOPN compared to RANKX?
Is there any advice you could please give me with best understanding TOPN and in what situation to use TOPN please.




Just remember with TOPN you are currently ranking by Product[Product Name]

You may be confused due to an error I had in the youtube clip, but I mention in the comments you may will want to change that part to a measure.

The big difference between this two is the TOPN is a table function while RANKX returns a scalar value.

It’s all about understanding the context you place these functions into.

Just try changing up the TOPN function as I’ve described and see if that changes things first.


Hi Sam,

I just had a bit of a general question as I am going through the learning modules. There are several times when you have referenced a DAX formula for filtering and things such as TOPN. I have noticed several of the visual layer filters and tools allow you to apply a filter or show TOPN or BOTTOMN. Is there a reason to do this in DAX instead of the Visualization tools/settings?

Great courses btw!



Hi Guner,

That’s great, glad you’re enjoying working through the content.

I would always use DAX. The main reason is because the filter you can apply at the visual level or page/report level can not be seen by consumers.

With DAX you can be very specific about what is being calculated with the DAX measure names, and everything gets filled in naturally, ie. visual and axis titles etc.

DAX is always the way to go. Start simple and then branch out to more complex calculations.

Occasionally I might use a page level filter to maybe filter dates for example but then I make sure it is very clear to the consumer what they are looking at.

Understanding what context is working on any calculation is very important for the consumer and in most cases for the developer. The more clear you can make this at all time is essential in my opinion.