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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RingoSun
Helper II
Helper II

Ranking a column from highest to lowest

So I have this BrandDim table and I want to rank them from highest to lowest.

RingoSun_1-1652346171369.png

 

So the value that I'll be using to rank them will be based on the quantity column of this SOS table 

RingoSun_2-1652346398978.png

 

 

And also do take note of the relationship of the tables

RingoSun_3-1652346441132.png

 

With all that said, I want a new column to be added to my BrandDim table and it would contain the ranking numbers. So whichever brand has the highest quantity will have 1 as its value in that new column, the second highest will have 2 and so on....

 

How do I achieve this?

 

PBIX FILE

1 ACCEPTED SOLUTION

@RingoSun , Try

Rank = if([Brand] <> "Client" , Rankx(Filter(BrandDim, [Brand] <> "Client") ,[Qty],,desc,dense), blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Querynalyst
Frequent Visitor

@kring,

 

You can first create a new table:

 

newBrandTable = SUMMARIZE(BrandDim, BrandDim[Brand], BrandDim[BrandId], "qty", SUM(SOS[Quantity]))

 

Then simply create a new column "rank"

 

rank = RANK.EQ(newBrand[qty], newBrand[qty])

 

Hope this can help

amitchandak
Super User
Super User

@RingoSun , If you need a column rank

Create a new column

Qty = Sumx(Relatedtable(SOS ), [Qty])

 

Rank = Rankx(BrandDim ,[Qty],,desc,dense)

 

 

Or measure based on qty

Rankx(allselected(BrandDim[Brand]), calculate(Sum(SOS[Qty])) ,, desc, dense)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Hi! the first option worked but I want to take this a step further. In my Brand column I want to exclude the Client row from the ranking and just put its default value as 1 or perhaps 0 in the Ranking column. The rest will be ranked from highest to lowest normally. Is that possible?

@RingoSun , Try

Rank = if([Brand] <> "Client" , Rankx(Filter(BrandDim, [Brand] <> "Client") ,[Qty],,desc,dense), blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors