Home > database >  How to sort the order of x-axis for bar chart in PowerBI?
How to sort the order of x-axis for bar chart in PowerBI?

Time:12-16

enter image description here

Hi everyone,

I have a bar chart as shown in the screenshot above. The order for first 2 bars are correct, but the order for subsequence bars in the chart are wrong. The 3rd bar should be the category of 2% - 3% and the 4th bar should be 3% - 5% etc... The correct sequence should follow the 1st column of my table below:

enter image description here

I tried the sorting option in the chart but no matter what I choose, it doesn't achieve my goal. May I know is there any way that I can use to achieve the order that I want? Any help will be greatly appreciated!

CodePudding user response:

Try a custom sort: *Completed based on data provided

  1. Click on 'Enter Data' under 'Home' in the table view enter image description here

  2. Create 2 columns: 1 that has the same name as the column you want to sort. 2 Order column with the custom order for these values.

  3. Enter each bar name in the [Class] column and the position you want it in, in the Order column. 1 means you want it to be first. enter image description here

  4. Select the new table and select the column that you want to custom sort. When you select it, the column tools toolbar will automatically appear.

  5. Select 'Sort by Column' under 'Column tools' and select 'Order' this will order the Class column by the numbers you have entered. enter image description here

  6. Unselected the used field that has not been custom sorted and tick the new field with the same name under TABLE 'SortOrder'.

enter image description here

After

enter image description here

  • Related