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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
sr12
Helper I
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?

 

Thanks in advance,

 

Screenshot 2021-09-22 111818.jpg

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

Hi @sr12 

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

Ailsamsft_0-1632449212237.png

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 .

Ailsamsft_1-1632449212239.pngAilsamsft_2-1632449212241.png

The final result is as shown :

Ailsamsft_3-1632449212244.png

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.

View solution in original post

7 REPLIES 7
v-yetao1-msft
Community Support
Community Support

Hi @sr12 

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

Ailsamsft_0-1632449212237.png

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 .

Ailsamsft_1-1632449212239.pngAilsamsft_2-1632449212241.png

The final result is as shown :

Ailsamsft_3-1632449212244.png

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.

amitchandak
Super User
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,

// Add other

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:
https://www.youtube.com/watch?v=KK1zu4MBb-c

 

@amitchandak ,

 

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?

 

Screenshot 2021-09-22 165114.jpg

@amitchandak,

 

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

Please see this article.

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!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat ,

 

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.

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

 

Screenshot 2021-09-22 160328.jpg

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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