Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi - looking for some help with a RankX DAX calculation. For illustrative purposes, I'm using a simple table with Category, SubCategory, and Value. I'd like to create a measure that ranks by Category for total value across all SubCategory.
Currently, the measure is:
Solved! Go to Solution.
A measure like this should work
CategoryRank = RANKX(ALL('Table'[Category]), CALCULATE(SUM('Table'[Value]), ALLEXCEPT('Table','Table'[Category])))
Hi @Anonymous ,
According to your description, my understanding is that you want to rank your data by category and subcategory in a measure. If anything is misunderstood, please tell me.
Would you please create a measure to determine whether it is a Category or SubCategory?
ISCategory = COUNTROWS('Table') = CALCULATE(COUNTROWS('Table'),ALL('Table'), VALUES('Table'[Category]))
Then create a measure for ranking:
CategoryRank = IF( [ISCategory], RANKX( ALLSELECTED('Table'[Category]),CALCULATE(SUM('Table'[Value]))), RANKX(ALLSELECTED('Table'[SubCategory]),CALCULATE(SUM('Table'[Value]))))
For more details, please refer to https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Ee2raMYlhUJEk0MhAdVhoEgB2k-iqHNU-NGNKfNW2a_6EA?e=DI5ibg
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi,
I am not sure of what you want but see if my solution in this file helps.
Ashish Sir,
I also need this solution for my office assigment please share the DAX formula. In my assinnments there area 5 categoriues like 2 Regions, 7 Zones, 24 Branches and 45 Area Sales Officers, i want to making ranking from between Retions, then Zones, then brnahes then area sales officers... please guide.
Hi,
I do not have that file now. Share some data and show the expected result.
Dear Sir,
Reference data is attached.
Thank You so much for support.
https://drive.google.com/file/d/18ULxB7JdQXjqQszXQHw9BQ28lazJsD5X/view?usp=sharing
Share the download link of Excel and/or PBI file and show the expected result clearly.
Dear Sir,
Reference data is attached.
Thank You so much for support.
https://drive.google.com/file/d/18ULxB7JdQXjqQszXQHw9BQ28lazJsD5X/view?usp=sharing
A measure like this should work
CategoryRank = RANKX(ALL('Table'[Category]), CALCULATE(SUM('Table'[Value]), ALLEXCEPT('Table','Table'[Category])))
Thank you very much! Definitely wasted too much time trying to figure this one out!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 43 | |
| 41 | |
| 22 | |
| 17 |
| User | Count |
|---|---|
| 183 | |
| 114 | |
| 93 | |
| 62 | |
| 45 |