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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Advanced RANKX help needed

Hi again,

 

I have another thread about this - but was unable to get the help I needed.  I think this is pretty complicated:

 

Here is a table visual in Power BI Desktop with dummy data I've created:

Capture1.PNG

 

I first need to sort this table by the 'Total Plan Paid' amount in descending order.  'Total Plan Paid' is a measure I created:

Total Plan Paid = CALCULATE ( SUM ( 'SQL Shock Claims Query'[Total Plan Paid] ) )
 
I also need to have the table sorted by the 'Charges' in descending order.
 
In other words I need the table to eventually look like this:
Capture2.PNG
 
As you can see, MemberID F2 is on top because the member's [Total Plan Paid] is the most.  F2's 'Charges' are also sorted properly because the hiearchy of sorting is [Total Plan Paid] first and then followed by 'Charges'.
 
Member C9 is second because their [Total Plan Paid] is second most.  Their 'Charges' are also sorted properly in descending order.
 
Member A6 is at the bottom because their [Total Plan Paid] is the least.  Their 'Charges' are also sorted properly in descending order.
 
The other part of the problem is that the field 'MemberID' is classified and I don't want to show that in the table.  So I was hoping to have some kind of field/rank where I could switch it out in place of MemberID.
 
So, in the very end I would hope the table would look like this:
Capture3.PNG
 
Any help would be great.  I've been trying to figure this out for the past day without any luck!
 
Andrew
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Figured it out:

 

This is what I needed/came up with:

 

 

RankOrder =
VAR MemberID =
CALCULATETABLE (
VALUES ( 'SQL Shock Claims Query'[MemberID] ),
ALLSELECTED ( )
)

VAR CurrentOrder =
SELECTEDVALUE ( 'SQL Shock Claims Query'[MemberID] )

VAR Result =
IF (
HASONEVALUE ( 'SQL Shock Claims Query'[MemberID] ),
RANKX (
MemberID,
'SQL Shock Claims Query'[MemberID],
CurrentOrder,
DESC
)
)
RETURN
Result

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Figured it out:

 

This is what I needed/came up with:

 

 

RankOrder =
VAR MemberID =
CALCULATETABLE (
VALUES ( 'SQL Shock Claims Query'[MemberID] ),
ALLSELECTED ( )
)

VAR CurrentOrder =
SELECTEDVALUE ( 'SQL Shock Claims Query'[MemberID] )

VAR Result =
IF (
HASONEVALUE ( 'SQL Shock Claims Query'[MemberID] ),
RANKX (
MemberID,
'SQL Shock Claims Query'[MemberID],
CurrentOrder,
DESC
)
)
RETURN
Result

Hi, @Anonymous 

Great to hear the problem got resolved! Please accept your reply above as solution to close this thread.

Other community members will easily find the solution when they get the same issue.

Best Regards,
Community Support Team _ Eason

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.