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

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

Reply
joshua1990
Post Prodigy
Post Prodigy

RANKX with two columns

Hi experts!

I have a sales table that shows me for each week the sales volume per article.

Year-Week Article Key 1 Key 2
2022-01 A 1 5
2022-02 A 2 2
2022-01 B 1 4
2022-02 B 2 5

 

Now I would like to get a Rank (calculated column) for each week based on Key 1 (primary) and Key 2 (secondary).

That means that all articles for each week should be ranked based on Key 1 first, and then based on Key 2.

I tried to do build first a total rank value using this:

Rank Total = 
Sales[Key1] + DIVIDE(Sales[Key2], 100)

 But this will not work since the range for both values is between 0 and 1.000.000.000

 

How would you do that?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the attached file if it suits your requirement.

One of ways to achieve this is, instead of using the amount directly from the column, try creating rank columns and then use those as a reference.

 

 


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

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the attached file if it suits your requirement.

One of ways to achieve this is, instead of using the amount directly from the column, try creating rank columns and then use those as a reference.

 

 


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

Click here to schedule a short Teams meeting to discuss your question.
tamerj1
Super User
Super User

Hi @joshua1990 
Please refer to attached sample file with the solution

1.png

Rank = 
RANKX (
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Year-Week] ) ),
    'Table'[Key 1] * 1000000 + 'Table'[Key 2]
)

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.