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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
JK-1
Frequent Visitor

RANKX - breaking ties

Hi, how can I make these 3 and 4 (as coloured in table example below), when the store priority is the same so it ties. Would I have to combine a general choice, such as Store Number, to allow an extra split to give out the full ranking number, I'd need to see 4 overall. I can't quite get to grips with the advice on Dense - and what may need to be combined to re-write the measure.

 

Thanks,

Rank Priority = RANKX(FILTER('Table 1','Table 1'[Postcode Area]=EARLIER('Table 1'[Postcode Area])),'Table 1'[Store Priority],,ASC)

[Table 1]    
Store NumberPostcode AreaStore Priority Rank
15SR1 1
27SR2 2
33SR3 3
2SR3 3

 

2 ACCEPTED SOLUTIONS
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from DataInsights , please allow me to add some more information:
Hi  @JK-1 ,

 

Here are the steps you can follow:

1. Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1739863007674.png

2. Create calculated column.

Rand = RAND()/100
Rank_Number =
RANKX(
    FILTER(ALL('Table'),
    'Table'[Store Number]=EARLIER('Table'[Store Number])&&
    'Table'[Postcode Area]=EARLIER('Table'[Postcode Area])),
    [Store Priority] + [Index]/1000000,,ASC,Dense)

3. Result:

vyangliumsft_1-1739863007675.png

 

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

@JK-1,

 

I added Tenant to the ALL and ORDERBY arguments, and added a PARTITIONBY argument for Store Number. The partition resets the rank numbering for each Store Number.

 

Rank Priority = 
RANK (
    DENSE,
    ALL ( 'Table 2'[Store Priority], 'Table 2'[Store Number], 'Table 2'[Tenant] ),
    ORDERBY ( 'Table 2'[Store Priority], ASC, 'Table 2'[Tenant], ASC, 'Table 2'[Store Number], DESC ),
    PARTITIONBY ( 'Table 2'[Store Number] )
)

 

DataInsights_0-1739884202082.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from DataInsights , please allow me to add some more information:
Hi  @JK-1 ,

 

Here are the steps you can follow:

1. Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1739863007674.png

2. Create calculated column.

Rand = RAND()/100
Rank_Number =
RANKX(
    FILTER(ALL('Table'),
    'Table'[Store Number]=EARLIER('Table'[Store Number])&&
    'Table'[Postcode Area]=EARLIER('Table'[Postcode Area])),
    [Store Priority] + [Index]/1000000,,ASC,Dense)

3. Result:

vyangliumsft_1-1739863007675.png

 

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

JK-1
Frequent Visitor

@DataInsights 

Thank you for that. Works perfectly.

 

Slightly different, but related ..where there might be various floors -called Tenant in column below- is there a way to adapt it to Rank (against the exact Store Number) and for any tiebreaker again give each an individual ranking based on associated Store Priority. 

Store NumberTenantPostcode AreaStore Priority Rank
2BSR1 1
2CSR1 2
2ASR3 3
15ASR1 1
15BSR3 2
27ASR2 1
33ASR3 1

@JK-1,

 

I added Tenant to the ALL and ORDERBY arguments, and added a PARTITIONBY argument for Store Number. The partition resets the rank numbering for each Store Number.

 

Rank Priority = 
RANK (
    DENSE,
    ALL ( 'Table 2'[Store Priority], 'Table 2'[Store Number], 'Table 2'[Tenant] ),
    ORDERBY ( 'Table 2'[Store Priority], ASC, 'Table 2'[Tenant], ASC, 'Table 2'[Store Number], DESC ),
    PARTITIONBY ( 'Table 2'[Store Number] )
)

 

DataInsights_0-1739884202082.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




DataInsights
Super User
Super User

@JK-1,

 

Try this calculated column using RANK.

 

Rank Priority = 
RANK (
    DENSE,
    ALL ( 'Table 1'[Store Priority], 'Table 1'[Store Number] ),
    ORDERBY ( 'Table 1'[Store Priority], ASC, 'Table 1'[Store Number], DESC )
)

 

DataInsights_0-1739720748445.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.