How to use RANKX to sort on 2 or 3 columns



Has anybody done a RANKX on multiple columns please?

I have been looking at different solutions in the Power BI community etc. but none of them have been satisfactory so far.

Let’s say I have the following columns:
Products, Period and Total Sales

Products: Name of all the products
Period: AY and LY (actual year and last year)
Total Sales: self-explanatory

In the Table Visual you can only sort by 1 measure so far, unfortunately.

What I would like is:

  • Sort by Highest Total Sales (DESC)
  • Sort by Product (ASC)
  • Sort by Period (ASC -> AY comes first, then LY)


Product AA - AY - Total Sales
Product AA - LY - Total Sales
Product BB - AY - Total Sales
Product BB - LY - Total Sales

Does anyone have an idea how to achieve this please?

Thanks in advance for your help.

Kind regards,


Hi Yogesh,

Can you place some images here of what you are seeing. I’m a bit confused as it seems like this isn’t actually a RANKX problem but a sorting problem?

You mentioned issues only sorting by one column, and then also reference the product column…so I’m a bit lost.

Some visuals would help.

I’ve included here some examples of using RANKX in different ways for reference.


Hello Sam,

Many thanks for your reply; I will definitely check out the links to the videos you sent and see if I can manage with them.

Yes, actually it’s a sorting issue, but since there is currently no possibility to do multiple sorting on columns in a table, I thought about creating a measure which I could use to sort the data in the way they are required to be.

Thanks in advance for your much appreciated time and cooperation.

Kind regards,