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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Tlotly
Helper V
Helper V

Ranking a rank measure returns 1

Good day 

 

Why does the following measure returns 1 for all rows? I'm basically trying to rank branches on two measures.

 

new_rank_par_01 = var _rank1 =  RANKX (
               ALLSELECTED ('Centre details' ),
               CALCULATE( [sumPO], ALLEXCEPT('Centre details','Centre details'[Branch Description]))
           ,,DESC,dense )  
  +
 
            RANKX (
               ALLSELECTED ('Centre details' ),
               CALCULATE( [PAR %], ALLEXCEPT('Centre details','Centre details'[Branch Description]))
               
           ,,ASC,dense )
       *1000
RETURN
RANKX ( ALL('Centre details'[Branch Description]), _rank1
           ,,ASC,dense )
 
Thanks in advance,
M

(Make it a data day!)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Tlotly 

 

Thank you for sharing!

 

As you describe: the branch code with the highest outstanding principal should be first.

PO_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE(SUM('Sheet1'[Principal Outstanding]), ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,DESC,dense ) 

 

vnuocmsft_0-1716540422573.png

 

new_rank_par_01 = 
RANKX(ALL('Sheet1'), [PO_rank] + [PAR_rank] * 1000,,DESC,Dense)

 

vnuocmsft_1-1716540519149.png

 

After the code is merged, it is as follows:

 

Measure new_rank_par_01 = 
var PAR_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE([PAR %], ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,ASC,dense ) 
var PO_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE(SUM('Sheet1'[Principal Outstanding]), ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,DESC,dense ) 

RETURN RANKX(ALL('Sheet1'), [PO_rank] + [PAR_rank] * 1000,,DESC,Dense)

 

vnuocmsft_2-1716540617294.png

 

Regards,

Nono Chen

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Tlotly 

 

I speculate that there could be a filtering issue.

 

You could simplify the code to make it easier to better check that the results in each section match.

 

To better help you solve your problem, please provide some dummy data, preferably in tabular form.

 

Regards,

Nono Chen

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

@Anonymous 

 

I did simplify the code. And I've atatched the sample report on the link below.

So to break the tie, I wanted to use Principal Outstanding i.e. a branch code with the highest principal outstanding should be ranked first.

 

https://www.dropbox.com/scl/fi/u03iwulit1a39zafpoifc/Rank_test.pbix?rlkey=tcumz6p2hhlflhobyag6fj9sr&st=b4dy4qt9&dl=0

 

 

 

Thank you in advance.

Anonymous
Not applicable

Hi @Tlotly 

 

Thank you for sharing!

 

As you describe: the branch code with the highest outstanding principal should be first.

PO_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE(SUM('Sheet1'[Principal Outstanding]), ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,DESC,dense ) 

 

vnuocmsft_0-1716540422573.png

 

new_rank_par_01 = 
RANKX(ALL('Sheet1'), [PO_rank] + [PAR_rank] * 1000,,DESC,Dense)

 

vnuocmsft_1-1716540519149.png

 

After the code is merged, it is as follows:

 

Measure new_rank_par_01 = 
var PAR_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE([PAR %], ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,ASC,dense ) 
var PO_rank = 
            RANKX ( 
                ALLSELECTED (Sheet1[Branch Code] ) ,
               CALCULATE(SUM('Sheet1'[Principal Outstanding]), ALLEXCEPT(Sheet1,Sheet1[Branch Code]))
           ,,DESC,dense ) 

RETURN RANKX(ALL('Sheet1'), [PO_rank] + [PAR_rank] * 1000,,DESC,Dense)

 

vnuocmsft_2-1716540617294.png

 

Regards,

Nono Chen

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

@Anonymous  Thank you very much. It's working perfectly now. I only changed the sorting order in the return measure to ASC since PAR takes precedence. Sorry for not making it clear in my initial response.

 

Tlotly,

Make it a data day!

Tlotly_0-1716544634156.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors