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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.