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
The table has 3 columns, [Company], [market], [sales], and the data is like the following:
| Company | market | sales |
| A | LOCAL | 1000 |
| B | LOCAL | 2000 |
| C | LOCAL | 3000 |
| D | EUROPE | 4000 |
| E | EUROPE | 5000 |
| F | EUROPE | 6000 |
| G | ASIA | 1000 |
| H | ASIA | 2000 |
| I | ASIA | 3000 |
I want to rank the sales using market as the parent, and the company as the child, with the following expected result:
| Company | Market | Sales | Ranking |
| A | LOCAL | 1000 | 3 |
| B | LOCAL | 2000 | 2 |
| C | LOCAL | 3000 | 1 |
| D | EUROPE | 4000 | 3 |
| E | EUROPE | 5000 | 2 |
| F | EUROPE | 6000 | 1 |
| G | ASIA | 1000 | 3 |
| H | ASIA | 2000 | 2 |
| I | ASIA | 3000 | 1 |
I tried many DAX on my own and cannot come up with an answer to achieve that. I would be appreicated if anyone of one can assist me.
Solved! Go to Solution.
@johnyip , Try a new column rank
Rank = rankx(filter(Table, [Market] = earlier([Market])), [Sales])
a measure rank
Rank = rankx(filter(all(Table[Market], Table[Comapany]), [Market] = max([Market])),calculate(Sum( [Sales])))
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Hi,
One of ways to solve this is to wrtie the measure like below.
Please check the below picture and the attached pbix file.
Hi,
One of ways to solve this is to wrtie the measure like below.
Please check the below picture and the attached pbix file.
Thank you for the answer, this works well too 🙂
@johnyip , Try a new column rank
Rank = rankx(filter(Table, [Market] = earlier([Market])), [Sales])
a measure rank
Rank = rankx(filter(all(Table[Market], Table[Comapany]), [Market] = max([Market])),calculate(Sum( [Sales])))
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Thanks for the answer, the output of my pbix file is just like what I expected. But it is unfortunate to say that I cannot share the sample data here, sorry for that.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |