cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

Sort the Order in the Stacked Bar chart

Hi Team,

 

My requirement is to sort the order in the Stacked bar graph as shown below. As you can see in the first stacked bar graph the Medium with value 3 is on top  and then Hard with value 2 is at bottom . I want this to be reversed means Hard with red color value 2 should come on top and then the Medium with value 3 should come bottom.

 

Here the legend is a "Calculated Column".

TPOD.png

 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate V
Advocate V

Re: Sort the Order in the Stacked Bar chart

Hi ,

 

I got the solution , i tried to create separate measures for hard,medium and easy and use them in Value box and arrange these measures as added so that it sorts the column charts as required.Chart.jpg

 

View solution in original post

12 REPLIES 12
Highlighted
Memorable Member
Memorable Member

Re: Sort the Order in the Stacked Bar chart

@ncbshiva

 

Cick on the 3 dots on the top right of the object:

1. Sort by (select the Measure)

2. Sort Ascending 

Highlighted
Advocate V
Advocate V

Re: Sort the Order in the Stacked Bar chart

Hi,

 

The is not working , it is changing the position of the x-axis.

Highlighted
Super User III
Super User III

Re: Sort the Order in the Stacked Bar chart

Hi,

 

you can change the sort order, using the "Sort by Column" button.

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column#sort-using-the-sort-by-column-butto...

 

Create a column with the sort order for each category ...

e.g. 3 (Hard) > 2 (Medium) > 1 (Easy)

... and use these with "Sort by Column" as surrogate sort column

 

best regards

 

Marcus

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

I work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #BetterTogether

Highlighted
Advocate V
Advocate V

Re: Sort the Order in the Stacked Bar chart

Hi,

 

Here my category column is calculated one and below is the formula for it.

 

IFCondition = IF('Capability Data'[Difficulty to Fill]="Hard" && 'Capability Data'[How large is the gap to fill]="1";"Hard";
IF('Capability Data'[Difficulty to Fill]="Hard" && 'Capability Data'[How large is the gap to fill]="2";"Hard";
IF('Capability Data'[Difficulty to Fill]="Hard" && 'Capability Data'[How large is the gap to fill]="3";"Hard";
IF('Capability Data'[Difficulty to Fill]="Medium" && 'Capability Data'[How large is the gap to fill]="3";"Hard";
IF('Capability Data'[Difficulty to Fill]="Medium" && 'Capability Data'[How large is the gap to fill]="1";"Medium";
IF('Capability Data'[Difficulty to Fill]="Medium" && 'Capability Data'[How large is the gap to fill]="2";"Medium";
IF('Capability Data'[Difficulty to Fill]="Easy" && 'Capability Data'[How large is the gap to fill]="3";"Medium";
IF('Capability Data'[Difficulty to Fill]="Easy" && 'Capability Data'[How large is the gap to fill]="1";"Easy";
IF('Capability Data'[Difficulty to Fill]="Easy" && 'Capability Data'[How large is the gap to fill]="2";"Easy";BLANK()
)))))))))
 
And if i create a new calculated field for the sorting and use that in the Sort by columns , i am getting below error.
Tpod1.PNG

 

 
 
Highlighted
Advocate V
Advocate V

Re: Sort the Order in the Stacked Bar chart

Hello,

 

Can anyone please help me with this sorting issue ?

 

Regards

Highlighted
Super User III
Super User III

Re: Sort the Order in the Stacked Bar chart

Hi,

 

could you calculate the category column in Power Query (M-Code)?

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

I work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #BetterTogether

Highlighted
Advocate V
Advocate V

Re: Sort the Order in the Stacked Bar chart

Not sure how to calcuate in M-code. I am not aware of the language.

Highlighted
Super User III
Super User III

Re: Sort the Order in the Stacked Bar chart

Hi,

 

that should help.

Add a custom column and calculate the catorgary column.

https://docs.microsoft.com/en-us/power-bi/desktop-add-custom-column

 

https://docs.microsoft.com/de-de/powerquery-m/power-query-m-language-specification

 

If expression

The if expression selects between two expressions based on a logical condition.

For example:

if 2 > 1 then
     2 + 2
else
    1 + 1

 

The first expression (2 + 2) is selected if the logical expression (2 > 1) is true, and the second expression (1 + 1) is selected if it is false. The selected expression (in this case 2 + 2) is evaluated and becomes the result of the if expression (4).

 

 

 

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

I work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #BetterTogether

Highlighted
Super User III
Super User III

Re: Sort the Order in the Stacked Bar chart

Gilbert Quevauvilliers blogged this today.

Multiple conditions for a conditional column in Power Query

https://www.fourmoo.com/2018/11/27/multiple-conditions-for-a-conditional-column-in-power-query/

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

I work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #BetterTogether

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors