Forum Discussion

Bravebart's avatar
Bravebart
Frequent Visitor
6 years ago
Solved

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
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Bravebart 

    I build a table like yours to have a test.

    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

    Filter Programme1,2,3:

    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. 

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Bravebart 

    I build a table like yours to have a test.

    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

    Filter Programme1,2,3:

    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. 

    • Bravebart's avatar
      Bravebart
      Frequent Visitor

      Hi Rico,

       

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

       

      Bravebart