Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
I would like to sort a stacked bar in Power BI.
However, the option button at the top-right corner doesn't seem to provide the sort feature.
Here are the sort criteria I want:
1. The longest bar first
2. The bar of which the green part is the longest first
Repeat the 2. again and again for the other colors.
Is that possible?
I tried this tutorial, but I had 2 problems
1. I couldn't implement the last step
2. The tutorial is not really what I want.. I want the sort options available right from the top-right button instead of in another table.
Here is the last step of the tutorial
With that in place, go to the Data view and add a New Column to the main table. Sort Order = RELATED(AuxTable[Sort Order])
-----------------------------------
My current stacked column settings are:
- Axis: number
- values: number
- Legend: text
Example of data:
[ { "x": 1, "y": 1000, "type": "car" }, { "x": 2, "y": 3000, "type": "car" }, { "x": 3, "y": 5000, "type": "car" }, { "x": 1, "y": 10000, "type": "plane" }, { "x": 2, "y": 13000, "type": "plane" }, { "x": 3, "y": 9000, "type": "plane" }, { "x": 1, "y": 2000, "type": "bike" }, { "x": 2, "y": 4500, "type": "bike" }, { "x": 3, "y": 8000, "type": "bike" } ]
Solved! Go to Solution.
Hi @Let,
The sort "The longest bar first" is available if the x-axis is type of Text.
How can I make it work even with numbers (for consistency) ? (Besides, if x-axis is the type of Text, the chart has an horizontal scrollbar)
To make the sort option work with numbers, you can just set X-Axis Type to "Categorical". However, with this option, all labels will be shown on the X-Axis, so an horizontal scrollbar will be shown up if the chart is not big enough.
Regards
@Let @v-ljerr-msft This option is not there. Is there any solution to this problem as of now ?
Maybe this used to work, however now there is not a 'Type' element under either of the axis sections.
Update:
The sort "The longest bar first" is available if the x-axis is type of Text.
How can I make it work even with numbers (for consistency) ? (Besides, if x-axis is type of Text, the chart has an horizontal scrollbar)
Where can I find the option to sort by "Longest Bar First"?
Oh, there it is. I'm posting a picture here to help the next lost Dashboarder. It'll be in the top right of your visualization.
Thank you so much - it's not easy to find! Worked a charm for me.
Hi comish, I don't think this preserved the sort order of the x-axis. Choosing that "Sort by Count of Change Type" makes the x-axis resorted by the x-axis values with highest bar (regardless of individual color size within a bar) to the lowest.
Hi Let,
In my stack bar,
Axis: text. Shown in ascending order. I am okay with this
Legend: text.
Value: Count of the column in legend.
I am still trying to figure out: while preserving the sort order of the x-axis (Data type: text, sorted ascending), how to sort longest bar first within each x-axis bar? Longest bar to shortest bar is determined by Value.
Any help is appreciated.
Hi,
I'm experiencing the same problem I've searched for the option longest bar first but I cannot find it.
My X-axis is of type text and the values are a count of type whole number.
Any suggestions.
Cheers
Can you please tell me how did you create a stcked bar chart with x-axis different data colors ?
Hey,
You already find a solution for this problem? I am facing the samen problem at the moment..
Hi @Let,
The sort "The longest bar first" is available if the x-axis is type of Text.
How can I make it work even with numbers (for consistency) ? (Besides, if x-axis is the type of Text, the chart has an horizontal scrollbar)
To make the sort option work with numbers, you can just set X-Axis Type to "Categorical". However, with this option, all labels will be shown on the X-Axis, so an horizontal scrollbar will be shown up if the chart is not big enough.
Regards