Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
@artjomsf , refer if this can help
https://www.proserveit.com/blog/ms-power-bi-topn-and-other
https://www.youtube.com/watch?v=UAnylK9bm1I
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
97 | |
85 | |
70 | |
67 |
User | Count |
---|---|
116 | |
109 | |
94 | |
79 | |
72 |