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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
fredo75
Frequent Visitor

How to order data on a clustered column chart

Hello all,

 

Could you help me to solve this issue:i have a chart(see below) of data with 3 periods.I used a clustered column chart in PBI, so I have 3 columns on 3 different periods, for example: p6=200, p9=300, and p12=0, but when I display a grouped histogram the columns are displayed like this: P12, P6, P9 even if I filter by ascending or descending sort, it is still not in order, it displays: P9, P6 and P12 or P12,P6 and P9.How can i fix this?

fredo75_1-1718897434084.png

 

fredo75_0-1718897282701.png 

fredo75_2-1718897680562.png

 

 

1 ACCEPTED SOLUTION
ExcelMonke
Super User
Super User

Hello,

You could consider creating a calculated column where you assign the order value to the period in the order you would like. So for example you can consider the following formula:

CalcColumn =
SWITCH(
Table[Period],
"p12", 1,
"p9",2,
"p6,3,
0
)

Then under your column tools, you can sort your period column by the order column





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

Proud to be a Super User!





View solution in original post

5 REPLIES 5
ajohnso2
Super User
Super User

Your sort order is evaluating in string not integer so technically it is correctly sorted. You can use ExcelMonke's solution or in your data view you can apply a different column (an integer column) to sort your period column by.

 

ajohnso2_0-1718899399556.png

 

mark_endicott
Super User
Super User

@fredo75 - if you would like to sort them in the order of P6, P9, P12, then you can add an Index column in Power Query, this can be used to sort the column later on. 

 

First head to Power Query and select "Add Column" then Index >> From 1

 

mark_endicott_0-1718899017123.png

After clicking "Close & Apply" you will have this column in your data, and on the table veiw you can use "Sort by column" to sort the Period column by your Index. To do this, click the Period column, then use the option from the toolbar to select Index:

 

mark_endicott_1-1718899206847.png

 

You can then sort by Period ASC in the Chart:

 

mark_endicott_2-1718899274313.png

 

If this works for you, please mark it as the solution.

 

 

 

 

 

 

Hello,

 

Hello,

 

Hello Mark,

Sorry for the late reply, but even when i click Close and Apply, i didn't get the column created with the Index from 1 in order to "Sort the Period column by  Index.I have only 2 choices.

Could you tell me how to sort out this issue?

@fredo75 - did you follow my steps to produce the Index column? 

 

If it has not appeared when you have clicked Close and Apply, then you will need to check your Power Query steps, if you have a remove columns step, this could be using "Table.SelectColumns" - Which you can find out by viewing the M Code in the advanced editor. If this is the case you will need to add the index column into the selected columns. You can do this by clicking the "cog" on the Removed Columns step in the "Applied Steps". 

ExcelMonke
Super User
Super User

Hello,

You could consider creating a calculated column where you assign the order value to the period in the order you would like. So for example you can consider the following formula:

CalcColumn =
SWITCH(
Table[Period],
"p12", 1,
"p9",2,
"p6,3,
0
)

Then under your column tools, you can sort your period column by the order column





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

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors