Forum Discussion
Calculate Rank based on Grade
Hi,
I m new to power bi, i want to calculate Rank based on Grade as desc value and Department.
| Version_Name | Mode | Grade | Department | Rank |
| FB.PS.M_6 | Stress | 3H-900 | Test | 1 |
| FB.PS.M_7 | Stress | 3H-810 | Test | 2 |
| FB.PS.M_8 | Uniform | 3H-810 | Test | 2 |
| FB.PS.M_9 | Uniform | 3H-809 | Test | 3 |
| FB.PS.S_10 | Stress | 3H-810 | ETC | 1 |
| FB.PS.M_10 | Degrade | 3H-720 | ETC | 2 |
| FB.PS.M_10 | Metal | 3H-720 | ETC | 2 |
Thanks
HI Anonymous
If so, you could try one of the two formula:
RANKing = RANKX(ALLEXCEPT('Table','Table'[Department]),CALCULATE(MAX('Table'[Grade])),,DESC,Dense)or
RANKing = RANKX(FILTER(ALLSELECTED('Table'),'Table'[Department] = MAX('Table'[Department])),CALCULATE(MAX('Table'[Grade])),,DESC,Dense)By the way, here is difference between ALL and ALLSELECTED in the measure:
http://tinylizard.com/all-vs-allselected/
Regards,
Lin
6 Replies
- AnonymousNot applicable
Hi Anonymous ,
Split your Grade Values in Power Query
Create a Calculated Column.
RANKing = RANKX(FILTER('Table','Table'[Department] = EARLIER('Table'[Department])),'Table'[Grade],,DESC,Dense)Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button) - amitchandakSuper User
Anonymous , For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415 - v-lili6-msftCommunity Support
HI Anonymous
You could just create a new column by this formula:
RANKing = RANKX(FILTER('Table','Table'[Department] = EARLIER('Table'[Department])),'Table'[Grade],,DESC,Dense)and it seems that you don't need to do Split for Grade column.
Regards,
Lin
- AnonymousNot applicable
Calculated column is working fine. My requirement is to create measure.Could you tell me how to create measure out of this?
- AnonymousNot applicable
HI Anonymous ,
Incase you need a measure.
Measure Rank = RANKX(FILTER(ALL('Table7'),'Table7'[Department] = MAX('Table7'[Department])),CALCULATE(SUM('Table7'[Grade])),,DESC,Dense)Regards,Harsh Nathani