Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have a table of data that has macroeconomic data on countries over a period of years. I am trying to assign a rank to each country based on their value, while still taking into account the Year, Indicator, and Grouping columns AND skipping over any blank Values. The end result would read like the "Rank" column in the below sample picture. I've tried adapting lots of different forum posts to my problem but nothing has been successful and I just cannot seem to figure it out..I know it should be possible with some combination of the Rankx(Filter(All( functions.
To me the logic would be something like: If the Value is not blank then Rank the country's value against all other nonblank country values within the same Indicator, Grouping, and Year.
I would also probably need to use RANKX function as I need a way to switch from ASC to DESC ranking depending on the Indicator, as for some indicators the lower value the better while others a higher value the better.
Here is a link to the file: http://www.filedropper.com/samplefile_6
I really appreciate any help, thanks in advance.
-Raj
Solved! Go to Solution.
You may refer to the measure below.
Rank Measure = RANKX ( CALCULATETABLE ( VALUES ( 'Country Mapping File'[ALL Country] ), ALLSELECTED ( 'Country Mapping File'[ALL Country] ) ), CALCULATE ( SUM ( 'TE Data'[Value 4 Column] ) ), , DESC, DENSE )
You may refer to the measure below.
Rank Measure = RANKX ( CALCULATETABLE ( VALUES ( 'Country Mapping File'[ALL Country] ), ALLSELECTED ( 'Country Mapping File'[ALL Country] ) ), CALCULATE ( SUM ( 'TE Data'[Value 4 Column] ) ), , DESC, DENSE )
@rajivraina
This worked for me! Now I have a question. The order is getting changed if do top N based on highest value and then filter to rank = 1. It shows rank = 1 for unique names but some of them disappers when I apply TOPN. Any suggestion?
@rajivraina I have similar solution at this post, you can change it as per your need.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k wrote:@rajivrainaI have similar solution at this post, you can change it as per your need.
Hi @parry2k,
Your solution does seem similar however it seems to be ranking based on a measure instead of a calculated column. I tried adapting your formula to my case but it does not achieve the ranking result I want, do you mind seeing where I messed up?
Rank Measure = RANKX( FILTER( ALL( 'TE Data'[Year1], 'TE Data'[Category], 'TE Data'[Country] , 'TE Data'[Grouping Column]), 'TE Data'[Year1] = MAX('TE Data'[Year1]) && 'TE Data'[Category] = MAX( 'TE Data'[Category]) && 'TE Data'[Grouping Column] = MAX('TE Data'[Grouping Column]) ), CALCULATE(SUM('TE Data'[Value 4 Column])), , DESC, Dense )
Thanks,
Raj
@rajivraina quick question, why you want to add this as column instead of measure?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k wrote:@rajivrainaquick question, why you want to add this as column instead of measure?
@parry2k I think you misunderstood, I want to add this as a measure, but my values that I am ranking by are in a column-- all my data is in columns. In your previous post the person had values coming from a measure. so I had to adapt the expression part of the Rankx formula you had to include this and idk if that's why it is not working:
CALCULATE(SUM('TE Data'[Value 4 Column]))
@rajivraina what result you are getting? Are you adding rank calculation as measure or column?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k wrote:@rajivrainawhat result you are getting? Are you adding rank calculation as measure or column?
@parry2k I am getting all 1's. I am adding this as a measure.
Here is a link to my file: http://www.filedropper.com/samplefile2
@rajivraina thanks for sharing the file but I'm not going to download from tht site with tons of adv. etc etc. please share thru onedrive/google drive.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k wrote:@rajivrainathanks for sharing the file but I'm not going to download from tht site with tons of adv. etc etc. please share thru onedrive/google drive.
Fair enough, do you have an email I can share through onedrive?
My company doesn't allow that option due to security concerns 😞 has to be either within the organization or to specific email address.
User | Count |
---|---|
92 | |
85 | |
77 | |
66 | |
62 |
User | Count |
---|---|
110 | |
95 | |
95 | |
64 | |
59 |