Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
manojk_pbi
Helper V
Helper V

help need in Sorting Stacked Bar charts

Hi Friends,

 

I am looking for a suggestion on adding sort in Stacked bar charts on Legends. Please suggest how this can be achieved. I don't see any option which sorts my data using legends. Attached the sample data on which i tried and also picture how it looks 

my expectation is - chart should be sorted with Type 1  and it's share by desc

Prod 6 

Prod 3

prod 8

Prod 4

Prod 1

prod 2

 

sample :

ProdActualType
prod11757.00Type1
prod12202.00Type2
Prod2244.00Type1
Prod2328.00Type2
Prod32145.00Type1
Prod3458.00Type2
Prod4164.00Type1
Prod4159.00Type2
Prod5206.00Type1
Prod51047.00Type2
Prod63010.00Type1
Prod6133.00Type2
Prod7931.00Type2
Prod8877.00Type1
Prod8592.00Type2

 

manojk_pbi_0-1711963700788.png

 

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Thank you for the mention @lbendlin .  PBI file attached.  Solved it with measures and is therefore dynamic.

Hope this helps.

Ashish_Mathur_0-1712013970890.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur , I will go through the measures and try to replicate in my application.

lbendlin
Super User
Super User

In the regular world a column can only be sorted by itself or by another column, not by a measure.  ( @Ashish_Mathur may know a trick using visual type switching )

 

Even a DAX column will result in a circular reference, so you would need to create that sort column in Power Query.

 

lbendlin_0-1711979270645.png

This of course no longer makes it dynamic.  But it produces the desired result.

 

lbendlin_1-1711979351970.png

 

 

 

 

@Ashish_Mathur , could you provide some suggestions here how can we do in visualization or any other methods

I have already shared my solution.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @lbendlin for your reply. I will try it on my data set. I am just wondering about performance of this query on data when we have large data. Data which i had provided is aggregated and sample. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.