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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Bravebart
Frequent Visitor

Two stage RankX

Hi All,

 

I have a RankX working well but now want a second RankX based on the results of the first. I use the results as my y-axis in a scatter chart.

 

This table shows how my RankX works and I've hidden some rows to show what I want to achieve. For each change of programme as seen in the Programme Index column I want the minimum value from the RankX of Index column.

 

Here's the measure for my RankX of Index:

Measure = RANKX(ALLSELECTED('Milestones'),'Milestones'[Index],CALCULATE(sum('Milestones'[Index])),DESC,Skip)
 
Any help appreciated.

 

ProgrammeProjectMilestonesIndexRankX of IndexProgramme Index
Programme 1Project 101/08/2020111
Programme 1Project 303/08/2020321
Programme 2Project 404/08/2020433
Programme 2Project 606/08/2020643
Programme 3Project 707/08/2020755
Programme 3Project 808/08/2020865
Programme 3Project 909/08/2020975
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Bravebart 

I build a table like yours to have a test.

1.png

Build measures to achieve your goal.

 

RankX of Index = RANKX(ALLSELECTED(Milestones),CALCULATE(sum('Milestones'[Index])),,ASC)
Programme Index = 
var _t = ADDCOLUMNS(ALLSELECTED(Milestones),"Rank",[RankX of Index])
return
MINX(FILTER(_t,[Programme] = MAX([Programme])),[Rank])

 

Result:

Default

2.png

Filter Programme1,2,3:

3.png

You can download the pbix file from this link: Two stage RankX

 

Best Regards,

Rico Zhou

 

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

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Bravebart 

I build a table like yours to have a test.

1.png

Build measures to achieve your goal.

 

RankX of Index = RANKX(ALLSELECTED(Milestones),CALCULATE(sum('Milestones'[Index])),,ASC)
Programme Index = 
var _t = ADDCOLUMNS(ALLSELECTED(Milestones),"Rank",[RankX of Index])
return
MINX(FILTER(_t,[Programme] = MAX([Programme])),[Rank])

 

Result:

Default

2.png

Filter Programme1,2,3:

3.png

You can download the pbix file from this link: Two stage RankX

 

Best Regards,

Rico Zhou

 

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

Hi Rico,

 

Thank you very much for helping with this. What you provided is exactly what I need. Well done.

 

Bravebart

Greg_Deckler
Super User
Super User

@Bravebart This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.

 

Little different in your case with RANKX but same concept.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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