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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
alex4597
Frequent Visitor

Change Order of Stacked Bar

In this line and stacked column chart I want the red bar to be on top of the green one, is there a way to do that?

 

REQ OTD Chart.png

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @alex4597 ,

 

First go to query editor,then add column> columns from example to add a column as below:

 #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Color] = "red" then 2 else if [Color] = "green" then 1 else null, type number)

Then back to data view>select column color>sort by column;

Screenshot 2020-09-28 162929.png 

And you will see:

beforebeforeafterafter

 

For the sample .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi  @alex4597 ,

 

First go to query editor,then add column> columns from example to add a column as below:

 #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Color] = "red" then 2 else if [Color] = "green" then 1 else null, type number)

Then back to data view>select column color>sort by column;

Screenshot 2020-09-28 162929.png 

And you will see:

beforebeforeafterafter

 

For the sample .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

negi007
Community Champion
Community Champion

@alex4597 You can do this by creating an another table like below and then link it to main table using color column.

 

negi007_0-1601047643263.png

 

Then you can do the sorting using the newly created column like below and have your chart legend in your desired sequence

 

negi007_2-1601047842790.png

 

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

amitchandak
Super User
Super User

@alex4597 , Change the color from data Color.

Or Create a new sort column the current legend that will reverse the sort order and mark that as the sort column

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.