cancel
Showing results 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.

Helper I

## Bars Sequence in Bar Charts

Hello

How can I change the sequence of the bars in the bar chart, for example for the "Others" bar in the below bar chart i would like to have it at the end. Is there any way to do this?

1 ACCEPTED SOLUTION
Community Support

Hi @sr12

The number at the end of your formula should be 11, not 10 .

You can number the sequence for column[Vertical], and then add this sequence column to your visual, so as to sort the bars in the visual through this sequence .

(1)Create a calculated column .

``````sequence =
SWITCH(TRUE(),'Table'[Vertical]="Residential",1,'Table'[Vertical]="Commercial",2,
'Table'[Vertical]="Banking",3,'Table'[Vertical]="Education",4,
'Table'[Vertical]="Entertainment/Sports",5,'Table'[Vertical]="Government",6,
'Table'[Vertical]="Healthcare",7,'Table'[Vertical]="Hospitality",8,
'Table'[Vertical]="Industrial",9,'Table'[Vertical]="Warehouses/Logistics",10,
'Table'[Vertical]="Others",11)``````

(2)Add the calculated column in Bar chart then sort by column [sequence] , select Sort ascending .

The final result is as shown :

I have attached my pbix file ,you can refer to it .

Best Regards

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

7 REPLIES 7
Community Support

Hi @sr12

The number at the end of your formula should be 11, not 10 .

You can number the sequence for column[Vertical], and then add this sequence column to your visual, so as to sort the bars in the visual through this sequence .

(1)Create a calculated column .

``````sequence =
SWITCH(TRUE(),'Table'[Vertical]="Residential",1,'Table'[Vertical]="Commercial",2,
'Table'[Vertical]="Banking",3,'Table'[Vertical]="Education",4,
'Table'[Vertical]="Entertainment/Sports",5,'Table'[Vertical]="Government",6,
'Table'[Vertical]="Healthcare",7,'Table'[Vertical]="Hospitality",8,
'Table'[Vertical]="Industrial",9,'Table'[Vertical]="Warehouses/Logistics",10,
'Table'[Vertical]="Others",11)``````

(2)Add the calculated column in Bar chart then sort by column [sequence] , select Sort ascending .

The final result is as shown :

I have attached my pbix file ,you can refer to it .

Best Regards

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

@sr12 , You can define on sequence /order by for vertical

new column=

Vertical 1= [Vertical]

Vertical sort = Switch(True() ,

[Vertical] ="residential", 1,

[Vertical] ="commerical", 2,

12)

Mark vertical sort as sort column for vertical 1 and use that in the visual

refer, if needed

How to Create Sort Column and Solve Related Errors:

Helper I

I added the above cod ein the "add column" but i got an error as shown in the below picture, how can i fix it?

Helper I

Can you please explain where to do this? I couldnt find the place to perform the above actions.

Employee

Sort one column by another column in Power BI Desktop - Power BI | Microsoft Docs

Pat

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

Helper I

Thanks for sharing, but its not exactly what i want. I want to change the sequence of the bars to let the "Others" bar be at the end of the bar chart.

Helper I

I should also mention that my table is an attribute as shown below:

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors