Forum Discussion
Ranking with multiple columns
- 4 years ago
Hi, Anonymous
Measures:
_Super Region Ranking = IF([_Total Services]<=0,0,RANKX(FILTER(ALL('Table2'),'Table2'[ Super Region ]=MAX('Table2'[ Super Region ])&&[_Total Services]>0),[_Total Services],,DESC,Dense))_Region Ranking = IF([_Total Services]<=0,0,RANKX(FILTER(ALL('Table2'),'Table2'[Region ]=MAX('Table2'[Region ])&&[_Total Services]>0),[_Total Services],,DESC,Dense))_Total Services = SUM('Table2'[ Security Total ])Result:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 4 years ago
Hi, Anonymous
The max function here is used to get the value of the current row. In the current row context, since there is only one row, no matter you use the MAX, MIN, or SELECTEDVALUE functions, it has the same effect.
Now to explain the above formula, first we look at the syntax of the RANKX function:So
_Super Region Ranking = IF( [_Total Services] <= 0, 0, RANKX( FILTER( ALL( 'Table2' ), 'Table2'[ Super Region ] = MAX( 'Table2'[ Super Region ] ) && [_Total Services] > 0 ), //Get all records in the same region and rank them in a sub-table of all rows in this same region. //Filter the sub-tables whose region in the entire table is equal to the region of the current row. [_Total Services], , DESC, DENSE ) )Hope this helps you understand.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
Do you want to get the ranking based on the Security Total value or the total Spend value? Notice that a region appears multiple times in the Super Region column, how to calculate their ranking? Is the % security spend column also the column that you want to add?
Could you please consdier sharing more details about it and posting expected result so it is clear on what needs to be implemented? And It would be great if there is a sample file without any sesentive information here.
It makes it easier to give you a solution.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello, I did replied to this post, not sure what happened to my reply. Sending you the sample data with results needed(bold cols). I want to rank with Security total only. The ones with 0 or -ve amount in security total has rank 0. I did correctly for salesrep ranking, Company Ranking = IF(OR('Calculations'[Total Services]=0,'Calculations'[Total Services]<0),0,RANKX(ALL('Security Data'),[Total Services])) Total Services is a measure for sum of security total.
| Region | Super Region | President | Sales Director | Super Region Ranking | SalesEep Ranking | SalesRep Name | Security Total | total Spend | % Security Spend |
| CA | West | A3 | Tan | 3 | 5 | Rob | 306,614 | 10,937 | 8% |
| CA | West | A3 | Tan | 4 | 6 | Emma | 246,627 | 10,937 | 5486% |
| FL | South | A6 | Med | 2 | 8 | Charlotte | 126,653 | 779,857 | 1% |
| FL | South | A6 | Med | 4 | 10 | Jose | 6,679 | 779,857 | 1% |
| GA | South | A10 | Ryan | 1 | 7 | Mia | 186,640 | 779,857 | 1% |
| GA | South | A10 | Ryan | 3 | 9 | Sam | 66,666 | 779,857 | 1% |
| MD | East | A2 | Mill | 2 | |||||
- v-angzheng-msft4 years agoCommunity Support
Hi, Anonymous
Try to create a measure like this:Company Ranking = IF([Total Services]<=0,0,RANKX(FILTER(ALL('Table'),'Table'[ Security Total ]>0),[Total Services],,ASC,Dense))Result:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Anonymous4 years agoNot applicable
Thanks for your reply, As mentioned in my reply, I had already achieved company ranking(sales rep ranking). I need help with other two, as mentioned earlier "Need help for Super Region Ranking, Region Ranking ".