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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Jkh30
Helper I
Helper I

RANKX with Multiple Criterias

Hi everyone,

 

I have a case that I need to rank clubs based on their points each week and if the point between each clubs are the same, it needs to compare based on Greater Goal deficit. Also if they have the same point and goal deficit, the rank needs to be sorted by Club name alphabeticaly. May anyone help me with this?

 

For example in the picture:

Crystal Palace should be at 20 rank and everything else should be 1, 2 ,3 and so on until 20. (not 1, 2 ,2 and so on)

Jkh30_0-1726299035570.png

 

Thank you everyone.

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

This can be solved with the RANK() function.  To receive further help, share the donwload link of the PBI file.  Is Greater Goal deficit the same as GD?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Hi,

Write this measure.  See the last column in the image.

Measure = RANK(DENSE,FILTER(ALL(Club),Club[ClubID]<>BLANK()),orderby([Points],DESC,[Goal Deficit],desc,Club[Club Name],ASC))

Hope this helps.

Ashish_Mathur_0-1726530199329.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

10 REPLIES 10
v-xingshen-msft
Community Support
Community Support

Hi ALL,
Firstly  Ashish_Mathur and TomMartens thanks you for yours solutions!
And @Jkh30 ,for your question, we can use rankx in the calculated column to accomplish your needs, we assign weights to Pts , GD and club name to make sure that they are guaranteed to be sorted in the order of Pts GD club name, I hope my method helps you!

Column = 
IF(
    ('club_data'[Club])="Crystal Palace",
    20,
    RANKX(
        ALL('club_data'),
        ('club_data'[Pts])*10000+('club_data'[GD])*1000+(1000-UNICODE(LEFT('club_data'[Club],1))),,DESC,Dense))

vxingshenmsft_0-1726450958198.png

I hope my solution is helpful to you, if you have more recent questions, you can always contact me and I will reply as soon as I see your message!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

 

Hello! Really appreciate your help on this matter. However, I kinda need this in a measure form not in calc table or column. Is it possible? Thank you!

Hi @Ashish_Mathur ,

I'm sorry, due to environmental constraints, I can't type your pbix file, so I'm going to follow the example data you've shown, and here's the idea of calculating the columns along the lines of the DAX in the measure, which I hope will be helpful to you!

Rank Measure = 
IF (
    SELECTEDVALUE('club_data'[Club]) = "Crystal Palace",
    20,
    RANKX (
        ALL('club_data'),
        CALCULATE(
            SUM('club_data'[Pts]) * 10000 +
            SUM('club_data'[GD]) * 1000 +
            1000 - UNICODE(LEFT(SELECTEDVALUE('club_data'[Club]), 1))
        ),
        ,
        DESC,
        Dense
    )
)

 

vxingshenmsft_0-1726545304494.png

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

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

 

Ashish_Mathur
Super User
Super User

Hi,

This can be solved with the RANK() function.  To receive further help, share the donwload link of the PBI file.  Is Greater Goal deficit the same as GD?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur here is the url to download the PBIX and CSV files as the data source:


EPL Reports

Thank you for your help!

Hi,

Write this measure.  See the last column in the image.

Measure = RANK(DENSE,FILTER(ALL(Club),Club[ClubID]<>BLANK()),orderby([Points],DESC,[Goal Deficit],desc,Club[Club Name],ASC))

Hope this helps.

Ashish_Mathur_0-1726530199329.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Splendid! Works beautifully!Thank you so much @Ashish_Mathur . I mark this as solution.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
TomMartens
Super User
Super User

Hey @Jkh30 ,

 

provide a pbix file containing sample data that still reflects your semantic model (tables, relationships, calculated columns, and measures), upload the file to OneDrive, Google Drive, or Dropbox and share the link. If you are importing the sample data from a spreadsheet instead of using the manual input method, share the spreadsheet as well. This is required to adapt the semantic model if necessary.

Do not forget to describe the expected result based on the sample data.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom, here is the url to download the PBIX and CSV file for datasource:

EPL Reports

Thank you for your help!

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors