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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
mitchemmonkey
Frequent Visitor

SUB RANKX HELP

I have the following table called SUMMARISE2, which I have ranked according to TEST2, called TESTRANK2. For each test name (i.e., TEST2/TESTRANK2) I then want to sub rank the rows based on value in "Lot No2", so that for each TEST2 category, I have a rank of 1,2,3 (and so on), which repeats for each test name it comes across. Note - The actual number currently in "Lot No2" is irrelevant and I just need to assign a 1,2,3 etc number to each independent variable in the group, and not specifically rank based on the actual value.

 

mitchemmonkey_0-1664291141551.png

 

Any help on the correct DAX expression would be appreciated

 

2 ACCEPTED SOLUTIONS

Hi, @mitchemmonkey 

These two rankings are independent of each other and don't seem to be that complicated.

I think the following two formulas will work.

Calculated columns:

TESTRANK2 = RANKX('Table','Table'[TETS2],,DESC,Dense)
Rank = RANKX(FILTER('Table','Table'[TETS2]=EARLIER('Table'[TETS2])),'Table'[LOT NO2],,DESC,Dense)

veasonfmsft_1-1664784961534.png

Other Related threads:

https://www.sqlbi.com/articles/rankx-on-multiple-columns-with-dax-and-power-bi/ 

 

Best Regards,
Community Support Team _ Eason

View solution in original post

Hi, @mitchemmonkey 

Try this:

Max rank = CALCULATE(MAX('Table'[Rank]),ALLEXCEPT('Table','Table'[TETS2]))

Best Regards,
Community Support Team _ Eason

View solution in original post

6 REPLIES 6
v-easonf-msft
Community Support
Community Support

Hi , @mitchemmonkey 

Can you share a simplified data table and expected results for further research ?

 

Best Regards,
Community Support Team _ Eason

@v-easonf-msft 

thanks for your reply - I'm pretty new to power BI so not sure what you refer to when asking for a simplified table, but I have mocked up in Excel what I want to acheieve:

 

mitchemmonkey_0-1664782526995.png

 

Essentially, I need to rank within each original ranked category (i.e., 1st rank on the test name [which ive done under "TESTRANK""column], but then rank within each test name based on different text within the Lot No2 column [Rank column in excel mock up picture])

 

I dont want to use the Power query/transform option, and hoping for a DAX solution 🙂

 

Thank you for your time.

Hi, @mitchemmonkey 

These two rankings are independent of each other and don't seem to be that complicated.

I think the following two formulas will work.

Calculated columns:

TESTRANK2 = RANKX('Table','Table'[TETS2],,DESC,Dense)
Rank = RANKX(FILTER('Table','Table'[TETS2]=EARLIER('Table'[TETS2])),'Table'[LOT NO2],,DESC,Dense)

veasonfmsft_1-1664784961534.png

Other Related threads:

https://www.sqlbi.com/articles/rankx-on-multiple-columns-with-dax-and-power-bi/ 

 

Best Regards,
Community Support Team _ Eason

@v-easonf-msft 

One more question. How do I change the DAX to reurnthe highest rank for each category:, i.e.,:

 

mitchemmonkey_0-1664869196641.png

 

Hi, @mitchemmonkey 

Try this:

Max rank = CALCULATE(MAX('Table'[Rank]),ALLEXCEPT('Table','Table'[TETS2]))

Best Regards,
Community Support Team _ Eason

@v-easonf-msft Perfect - thank you!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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