Sort one column by another column in Power BI

In this exercise, we will learn how to define the sort order of column by another column in the table.

The following table is the data that we are using for the demonstration.

Month NoSalaryMonth
117000Jan
220000Feb
314000Mar
445000Apr
576568May
632445Jun
734568Jul
876457Aug
998578Sep
1090657Oct
1124678Nov
1220570Dec

Step 1: Let’s create a visual with Month and Salary column from the table. In the X-axis we have Month column, and, in the Y-axis, we have the Salary column.

We can see from the visual, that the months are being sorted alphabetically: Apr, Aug, Dec, Feb, and so on. However, we want them to be sorted chronologically i.e. Jan, Feb, Mar and so on.

Sort by column in Power BI

Step 2: In order to achieve the chronological order, we are using the Month no column of the table. So here what we are going to do, we will sort the Month column on the basis of Month no column of the table.

Step 3: Select the column that we want to sort, in this case, Month column from the table. Note that the months in the visual are sorted alphabetically. In the Fields pane, the Column tools tab becomes active.

Sort by column in Power BI

Step 4: Select Sort by column tool, then select the field we want to sort the other field by, in this case, Month no.

Sort by column in Power BI

Now we can see that the visual automatically sorts chronologically by the order of months in a year.

Sort by column in Power BI

Please note that if the Month column is used anywhere in the report, there is it is automatically sorted by the Month no column. So, we can say that the effect of this Sort by column feature is at the report level.