cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to sort stacked column chart in Power BI desktop?

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.

 

Screenshot_1.png

 

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"
    }
]

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: How to sort stacked column chart in Power BI desktop?

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. Smiley Happy

 

r2.PNG

 

Regards

View solution in original post

7 REPLIES 7
Highlighted
Frequent Visitor

Re: How to sort stacked column chart in Power BI desktop?

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)

Highlighted
Microsoft
Microsoft

Re: How to sort stacked column chart in Power BI desktop?

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. Smiley Happy

 

r2.PNG

 

Regards

View solution in original post

Highlighted
Helper II
Helper II

Re: How to sort stacked column chart in Power BI desktop?

Where can I find the option to sort by "Longest Bar First"?

Highlighted
Helper II
Helper II

Re: How to sort stacked column chart in Power BI desktop?

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.

 

SortByCount 20180207.jpg

Highlighted
Regular Visitor

Re: How to sort stacked column chart in Power BI desktop?

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.

Highlighted
Frequent Visitor

Re: How to sort stacked column chart in Power BI desktop?

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.
Untitled.png
Any suggestions.

Cheers

Highlighted
Frequent Visitor

Re: How to sort stacked column chart in Power BI desktop?

Hey,

 

You already find a solution for this problem? I am facing the samen problem at the moment..

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors