cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Resolver II

## 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 )

M

(Make it a data day!)

1 ACCEPTED SOLUTION
Community Support

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 )
``````

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

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)``````

Regards,

Nono Chen

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

4 REPLIES 4
Community Support

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.

Regards,

Nono Chen

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

Resolver II

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&...

Community Support

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 )
``````

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

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)``````

Regards,

Nono Chen

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

Resolver II

@v-nuoc-msft  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!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors