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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
johnyip
Super User
Super User

Rank values stored in a list (PathValue)

Hello there, I am here to ask some weird question again.

 

I have created a "list", which can be passed into the IN opeartor, as the below hyperlink:

 

Solved: Pass the selected values of a slicer into the IN o... - Microsoft Power BI Community

 

My question is, how  to rank the values of such a list?

 

For example, if the list is {46,283,133,233,34}, I would like to rank it as {2,5,3,4,1}.

I hope I can achieve tat by using some DAX in a measure, because the "list" is generated in a measure, and I need to retrieve the ranked value and pass it into the measure.

 

Thanks a lot.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!
1 ACCEPTED SOLUTION

I figured out the solution myself.

 

It is to use the same trick as this link to generate a lookuptable with both old rank and new rank using SELECTCOLUMNS(), like this:

 

VAR LookupList =
SELECTCOLUMNS(
GENERATESERIES ( 1, PATHLENGTH ( PathVar2 ) ),
"Old Rank", VALUE(PATHITEM ( PathVar1, [Value])),
"New Rank", VALUE(PATHITEM ( PathVar2, [Value] ))
)
 
And then finally return:
MAXX(FILTER(LookupList,[Old Rank] IN {MAX('Table'[Column])}),[New Rank])
 
 
Tricky enough though.
 
I have take this link regarding mimiking loops in DAX. I also put it here for reference.

 

 



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@johnyip , I think concatenatex on the rank measures with values should give you that

 

concatenatex(Values(Table[Column]), [Rank])

 

But I doubt the order. May you have build both using same order column in concatenatex

@amitchandak , I am using that "list"  to select records of some companies with the ranks specified in that "list".

 

After this selection, I wish to rank all those selected companies' ranks based on their actual rankings (that is the value in that list), and then map this new ranking to the respective selected companies in a measure.

 

Any ideas on that? Because the data is in a summarized table and I need to doall these tricks to make slicers in the report working.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

I figured out the solution myself.

 

It is to use the same trick as this link to generate a lookuptable with both old rank and new rank using SELECTCOLUMNS(), like this:

 

VAR LookupList =
SELECTCOLUMNS(
GENERATESERIES ( 1, PATHLENGTH ( PathVar2 ) ),
"Old Rank", VALUE(PATHITEM ( PathVar1, [Value])),
"New Rank", VALUE(PATHITEM ( PathVar2, [Value] ))
)
 
And then finally return:
MAXX(FILTER(LookupList,[Old Rank] IN {MAX('Table'[Column])}),[New Rank])
 
 
Tricky enough though.
 
I have take this link regarding mimiking loops in DAX. I also put it here for reference.

 

 



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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