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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi all,
I have a table with data with sales per client per month, something simple like this:
Where I can achive ranking with RANKX.
Next I need: for each month to determine top-3 clients by "Amount" and compare see how much of total they do have, i.e. steps would be:
In the end Im looking for output like this:
So far I could do just RANKX ranking that does work with clients and months:
ClientRank = RANKX (ALL(clients[Client]), calculate(sum(clients[amount])))
but now I am struggling with having them aggregated in two groups. Is there a way to achieve that?
Thanks!
Solved! Go to Solution.
@artjomsf Create a disconnected table using an Enter Data query that contains 2 rows. Top 3 and Others
Construct a measure like:
Measure =
VAR __Category = MAX('DisconnectedTable'[Value])
VAR __Table = ADDCOLUMNS(SUMMARIZE('clients',[Client],[Month],"amount",[amount]),"rank",[ClientRank])
VAR __Top3 = FILTER(__Table,[rank]<=3)
VAR __Others = FILTER(__Table,[rank]>3)
VAR __Amount = IF(__Category = "Top-3",SUMX(__Top3,[amount]),SUMX(__Others,[amount]))
RETURN
__Amount
@artjomsf Create a disconnected table using an Enter Data query that contains 2 rows. Top 3 and Others
Construct a measure like:
Measure =
VAR __Category = MAX('DisconnectedTable'[Value])
VAR __Table = ADDCOLUMNS(SUMMARIZE('clients',[Client],[Month],"amount",[amount]),"rank",[ClientRank])
VAR __Top3 = FILTER(__Table,[rank]<=3)
VAR __Others = FILTER(__Table,[rank]>3)
VAR __Amount = IF(__Category = "Top-3",SUMX(__Top3,[amount]),SUMX(__Others,[amount]))
RETURN
__Amount
thanks a lot! That worked like charm! Just one more thing:
I have reworked that to match yearly instead of monthly data (which does not really matter), but I have calculation of total not right:
It shows Grand Total same as "Top-3" total. Could there be a solution to that?
@artjomsf Ah yes, Measure Totals. This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907