Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 :
| Prod | Actual | Type |
| prod1 | 1757.00 | Type1 |
| prod1 | 2202.00 | Type2 |
| Prod2 | 244.00 | Type1 |
| Prod2 | 328.00 | Type2 |
| Prod3 | 2145.00 | Type1 |
| Prod3 | 458.00 | Type2 |
| Prod4 | 164.00 | Type1 |
| Prod4 | 159.00 | Type2 |
| Prod5 | 206.00 | Type1 |
| Prod5 | 1047.00 | Type2 |
| Prod6 | 3010.00 | Type1 |
| Prod6 | 133.00 | Type2 |
| Prod7 | 931.00 | Type2 |
| Prod8 | 877.00 | Type1 |
| Prod8 | 592.00 | Type2 |
Thank you for the mention @lbendlin . PBI file attached. Solved it with measures and is therefore dynamic.
Hope this helps.
Thanks @Ashish_Mathur , I will go through the measures and try to replicate in my application.
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.
This of course no longer makes it dynamic. But it produces the desired result.
@Ashish_Mathur , could you provide some suggestions here how can we do in visualization or any other methods
I have already shared my solution.
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |