Custom sorting in PowerBI chart

Abhi picture Abhi · Jul 4, 2016 · Viewed 33.6k times · Source

Recently I came across one issue in which I need to show the column order as per my defined way in PowerBi report. Thing is, PowerBI sorts the columns in either Ascending(A->Z) or descending(Z->A) order, then if one has to apply his custom order how he should achieve this?

Here is and example

Here we can see the order on X-Axis is ascending or we can show it descending, but what if i would like to sort the order with respect to my need; may be as below :

1.2 Wheel Preview --> 1.2 GTR --> 1.2 Ultra --> 1.2 RTR

, Would it be possible in PowerBI desktop while creating the report, if yes, then guidelines to be followed will be well appreciated. :)

Thanks.

Answer

teylyn picture teylyn · Jul 5, 2016

Add a column to your source data and populate it with values for the desired sort order. Then select the column you want to custom sort and click Modeling > Sort by Column. Select the new column as the SortBy column for the existing column, like in the screenshot: The SortCategory column is used as the sort order for the Category column.

enter image description here

Now create a chart and the categories on the axis will be sorted according to the values of the SortCategory column.

enter image description here