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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jeremy19
Helper III
Helper III

Create an index measure in a matrix

Hello,

I have a seemingly simple problem that I can't seem to solve. I want to add an index measure to a matrix.

To simplify, my data looks like this:

idMinutes
A10
A15
A20
B5
B15

 

and I have a matrix filtered by id=A with only the minutes column. 

I have created a measure :  

Measure = MIN(Feuil1[Minutes])
and an index measure :
Rank = RANKX(ALLSELECTED(Feuil1[Minutes]),[Mesure],,DESC)
I obtain this result :
Jeremy19_0-1715496455193.png

But I would like to have the reverse order, but change DESC to ASC, I obtain :

Jeremy19_1-1715496539911.png

Do you know how to calculate this rank correctly?

 

Thanks

 

1 ACCEPTED SOLUTION
hackcrr
Super User
Super User

Hi, @Jeremy19 

The main reason why you get wrong sorting result under ASC sorting is that the current rank is also affected by id=B, e.g. 10 should correspond to a rank of 1.

You should change your DAX expression to look like this:

Rank = RANKX(ALLSELECTED('Feuil1'),[Mesure],,DESC)

 The DAX used in my tests is as follows:

rank = 
RANKX(ALLSELECTED('Table'),[Measure],,ASC,Dense) 

This DAX does a good job of returning the correct ranking results:

hackcrr_0-1715501103732.png

hackcrr_1-1715501112432.png

hackcrr_2-1715501129669.png

 

 

Best Regards,

hackcrr

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
ThxAlot
Super User
Super User

A more generic solution,

ThxAlot_0-1715507760871.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



hackcrr
Super User
Super User

Hi, @Jeremy19 

The main reason why you get wrong sorting result under ASC sorting is that the current rank is also affected by id=B, e.g. 10 should correspond to a rank of 1.

You should change your DAX expression to look like this:

Rank = RANKX(ALLSELECTED('Feuil1'),[Mesure],,DESC)

 The DAX used in my tests is as follows:

rank = 
RANKX(ALLSELECTED('Table'),[Measure],,ASC,Dense) 

This DAX does a good job of returning the correct ranking results:

hackcrr_0-1715501103732.png

hackcrr_1-1715501112432.png

hackcrr_2-1715501129669.png

 

 

Best Regards,

hackcrr

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

 

qqqqqwwwweeerrr
Super User
Super User

Hi @Jeremy19 

 

Is this what your expectation is 
qqqqqwwwweeerrr_0-1715499597376.png

i have used this measure: 

Rank = RANKX(ALLSELECTED('Table'[id],'Table'[Minutes]),[Measure],,ASC,Dense)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

Regards

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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