Forum Discussion

Vaishali0209's avatar
Vaishali0209
Regular Visitor
3 years ago

Need Help with 100% Stacked Bar chart

Hi Everyone, 

I have a 100% Stacked bar chart viz in which the legend categories are 380 values to display the % for each company. Now I want to sort that to see only top 5 companies for each row. How can I do that ?

 

 For example, for above chart for row 16 I want to see only top 5 contributor and similarly for each row. 

 

Pls help me !

5 Replies

  • Hello Vaishali0209 ,

    You can create ranking for each category and then apply using filters on this visual. For example, I have created some sample data like this:

    ProductSub-ProductSales
    Product 1Product A26
    Product 1Product B25
    Product 1Product C60
    Product 1Product D15
    Product 1Product E27
    Product 1Product F99
    Product 1Product G38
    Product 1Product H37
    Product 2Product I70
    Product 2Product J65
    Product 2Product K92
    Product 2Product L36
    Product 2Product M64
    Product 2Product N48

     

    Then created new column in Power BI desktop using below logic:

     

    Top 5 Contributors = 
    RANKX(FILTER('Table','Table'[Product]=EARLIER('Table'[Product])),'Table'[Sales])

     

    Then your output table looks as below:

    Now in the report view, create your visual and under visual level filters add this new column and under advanced filtering provide lessthan or equal to 5 this will solve your requirement. Your output visual looks like this:

    If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

     

     

     

  • Hi Kishore_KVN 

    Thank you for your reply and providing me with the DAX formula. I tried that and now my visual is turning into below:

     

     

    Many rows are appearing blank, and i do not want that.  Can you help me with that?