Latest Enterprise DNA Initiatives

Power Bi DAX Dynamic ranking

Hi All,

Currently I am using top N pattern to calculate the top 3 product

Top 3 Sales Campaign Group Total.Sales per Segment =


RankingContext = VALUES( Products[ProductName] )


CALCULATE( [Total Sales],

TOPN( 3,

ALL( Products[ProductsName]),

[Total Sales] ,DESC),


However now i want the top products based on total sales and profit margin.

Kindly request you to guide me with the logic for the same.

I would suggest you watch the following video from Sam on RANKX to help solve your question. Also, before posting questions in the forum, please do a search for your topic at the top right portion of the screen, there are several questions that are very similar to your question that have been posted.


Hi @JarrettM,

Thanks alot for the kind help, I have gone through this video before. Whereas my requirement is to rank the Product based on two different measure values i.e. Total sales and Profit Margin. In the video only total sales is getting ranked based on different context such as product , product category and product sub category.

But I needed the top 3 based on of Profit Margin based Total sales. I got the solution while replying back to this
Solution is basically create the top 3 measure of Profit margin based on Total Sales.

Thanks alot for looking into the query and energizing me to find the solution:)

Please post a snapshot of your solution. You never know who this might help out in the future!


1 Like