Forum Discussion

rauniyara's avatar
rauniyara
Regular Visitor
7 years ago
Solved

Top 5 Values filter by Legend

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 th...
  • Thejeswar's avatar
    7 years ago

    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

    Top 5 Products displayed separately. All the other products are grouped as "Others". If any year has other product which is not present in any of the other year, then that will be displayed only for that particular year. In such case, the legend will have 6 values. So you should hide the legend in that case

     

     

    Here is the link for the PBIX file for your reference

     

    Hope this is what you need!!!