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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Alirezam
Helper V
Helper V

Sorting a bar chart

I am trying to sort a bar chart on its legend (Yellow to be on the left to Red on the right). When I choose "sort by column" it sorts the legend alphabeticalley as appeared below that I don't want.

Also, If I use the ascending/descending option from the top right corner of the chart, the months order craps !

Thank you for your time.

Capture.PNG

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Create a 2 column Table with Meter types in column A and numbers denoting desired sort order of meter type in column B.  So against Mental health, there should be 1 and agsinst Manua Rd. should be a 4.  Create a relationship from the Meter Type column of your Table to the Meter Type column of this new Table.  In your Data Table. write this calculated column formula to bring over the order from the new Table

Order = RELATED('Meter Type'[Order])

In your Table, click on any cell in the Meter Type column and go to Sort By Column > Order.

To your visual, drag Meter Type from your Table.

Does this work?  If not, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Create a 2 column Table with Meter types in column A and numbers denoting desired sort order of meter type in column B.  So against Mental health, there should be 1 and agsinst Manua Rd. should be a 4.  Create a relationship from the Meter Type column of your Table to the Meter Type column of this new Table.  In your Data Table. write this calculated column formula to bring over the order from the new Table

Order = RELATED('Meter Type'[Order])

In your Table, click on any cell in the Meter Type column and go to Sort By Column > Order.

To your visual, drag Meter Type from your Table.

Does this work?  If not, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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