DEV Community

Cover image for Sort one column by another column in powerBI
Emmanuel Udoh
Emmanuel Udoh

Posted on

Sort one column by another column in powerBI

When you are given a task to complete and you find out that you need to sort a column by another column, for example, sorting the month name by the month number, this is what to do.

After you have added the month name to a visual, sometimes, it will be in alphabetical order; April, August, December and so on as shown in the picture below.

Image description

Sometimes, it might not be in alphabetical order. Don't panic. Just read on.

Set the column to use for sorting

To sort a column, you need a column with a number for each month in order to properly carry out the task. Any graphic in the report that has a sorted column will follow the order specified in the sorting. The months in the sample below are arranged alphabetically, but they ought to be arranged chronologically.

Image description

Steps to carry out this task:

  1. Select the column that you want to sort, in this case, month name. Note that the months in the graph are sorted alphabetically. In the Fields pane, the Column Tools tab becomes active.

Image description

  1. Select Sort by Column, then select the field you want to sort the other field by, which is, Month Number in this case.

Image description

  1. The graph automatically sorts chronologically by the number of months in a year.

Image description

Top comments (0)