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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
anshusaketsingh
Frequent Visitor

Unexpected Ranking Behavior When Adding Dimensions in Power BI

I was working with the RANK function to rank sales by Sub-Category, and it works fine when only Sub-Category is in the table. However, when I add another dimension (like a different field), the ranking behaves unexpectedly—it starts from 2 and then jumps to 4, instead of starting from 1 and ranking sequentially. I want the ranking to always reflect the individual ranking of Sub-Categories, regardless of any additional fields, with only slicers influencing the result. I’m trying to understand why this is happening and how to correct it.

 

Let me know if you’d like help reviewing or adjusting your DAX formula too!

anshusaketsingh_0-1745275286501.png

 

Power BI Workbook 

 

Here are DAX 

 

Total Saless All Except Sub-Cat With Slicer = CALCULATE([Total Sales],ALLEXCEPT(Orders,Orders[Sub-Category],Orders[Region]))
 
Sub-Category Ranking =
RANKX(ALLSELECTED(Orders[Sub-Category]),[Total Saless All Except Sub-Cat With Slicer],,,DENSE)
2 ACCEPTED SOLUTIONS

Hi,

Thank you for your message, and in my opinion, please try to write the measures like the attached file.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

Thanks , this really helps. The issue was never the Rankx but the underlying measure .

 
[Total Saless All Except Sub-Cat With Slicer]=CALCULATE([Total Sales], ALLSELECTED(Orders),VALUES(Orders[Sub-Category]))

Once I changed that , RankX worked like a charm without need to summarize 

Sub-Category Ranking =

RANKX( ALLSELECTED ( Orders[Sub-Category]), [Total Saless All Except Sub-Cat With Slicer],,,Dense)

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi,

Please try writing a measure something like below whether it suits your requirement.

 

RANK function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_0-1745290536594.png

 

 

Sub-Category Ranking = 
RANK (
    DENSE,
    SUMMARIZE ( ALLSELECTED ( Orders ), Orders[Sub-Category], Orders[Segment] ),
    ORDERBY ( [Total Saless All Except Sub-Cat With Slicer], DESC )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thanks a lot for responding to my query. The RANK function, as you mentioned, gives the desired result, but I’m still curious to understand why the RANKX function doesn’t behave as expected in my case. This is more of a learning opportunity for me than just applying a fix, so I’d really appreciate it if you could help me understand what I might be doing wrong with RANKX, and how to achieve similar results using it correctly.

Hi,

Thank you for your message, and in my opinion, please try to write the measures like the attached file.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thanks , this really helps. The issue was never the Rankx but the underlying measure .

 
[Total Saless All Except Sub-Cat With Slicer]=CALCULATE([Total Sales], ALLSELECTED(Orders),VALUES(Orders[Sub-Category]))

Once I changed that , RankX worked like a charm without need to summarize 

Sub-Category Ranking =

RANKX( ALLSELECTED ( Orders[Sub-Category]), [Total Saless All Except Sub-Cat With Slicer],,,Dense)
amitchandak
Super User
Super User

@anshusaketsingh ,  can also include region in Rankx and Try

 

Sub-Category Ranking =
RANKX(ALLSELECTED(Orders[Sub-Category],Orders[Region]),[Total Saless All Except Sub-Cat With Slicer],,,DENSE)

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

Your formula didn't work. Even if it did, it would make the ranking inconsistent, especially when another region dim is added to the table as region as dimension shouldn't impact ranking.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors