The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I have a Stacked Column Chart with Spend vs Fiscal Year data. The Total Spend columns are broken down into Material Category spend values through the Legend field.
How do I make it so that only the top 5 Material Categories by Spend are shown in detail within the columns and all other categories are grouped together as "Other" in the Legend? I can get just the TOP N Material Categories by Spend on the chart, but this will not include the "Other" Group consisting of all other categories.
I appreciate any help! Thank you!
Avi
Solved! Go to Solution.
Hi @rauniyara,
Try doing the following steps to get the chart as per your need
1. Generate the Rank based on Revenue grouped by Year in a Calculated Column
2. Create another Calculated column which should give product name only for Top 5 Products by Revenue and for other products as "Others"
The Follwing is the DAX used
Rank = RANKX(FILTER('Top5Filter', 'Top5Filter'[Year] = EARLIER('Top5Filter'[Year])), 'Top5Filter'[Revenue],,DESC,Dense)
This Rank is completely dynamic. Suppose a new value is going to be added in the future, this Rank will change accordingly
Top Product = IF('Top5Filter'[Rank] <= 5, 'Top5Filter'[Product], "Others")
The Below is the screenshot after applying these steps
Here is the link for the PBIX file for your reference
Hope this is what you need!!!
Hi @rauniyara,
Try doing the following steps to get the chart as per your need
1. Generate the Rank based on Revenue grouped by Year in a Calculated Column
2. Create another Calculated column which should give product name only for Top 5 Products by Revenue and for other products as "Others"
The Follwing is the DAX used
Rank = RANKX(FILTER('Top5Filter', 'Top5Filter'[Year] = EARLIER('Top5Filter'[Year])), 'Top5Filter'[Revenue],,DESC,Dense)
This Rank is completely dynamic. Suppose a new value is going to be added in the future, this Rank will change accordingly
Top Product = IF('Top5Filter'[Rank] <= 5, 'Top5Filter'[Product], "Others")
The Below is the screenshot after applying these steps
Here is the link for the PBIX file for your reference
Hope this is what you need!!!
Hi @Thejeswar,
Thank you for looking into this! Using the Rank and Calculated column allows me to get what I was looking for.
Appreciate your help!
Hi,
I am not sure of whether i can solve this problem completely. Nevertheless, I'd like to try. Could you share the link from where i can download the PBI file?
If you drag the category over into the values field then there should be a visual level filter beneath that to select "Top N"
Hi @rauniyara,
You have to create a DAX measure for that. Try this: http://geekswithblogs.net/darrengosbell/archive/2016/06/04/179446.aspx
- Marc
Oh, you are right. I misred that. Okay, this is what I would do. If it's the best practice, I don't know.
I would add a column with an "if" statement to get the names to what you want. If materials1 then materials1, if materials2, then materials2 and so forth, then use the else to group everything else into "other". Use that column as your categories.
That is true. You cannot place a TopN filter and then also use a basic filter (one would overlap the other). DAX will be the only option. Before you go there, I would get all categories in one columnto simplify things.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
119 | |
86 | |
75 | |
55 | |
44 |
User | Count |
---|---|
136 | |
128 | |
78 | |
64 | |
63 |