Forum Discussion

AlphaTau's avatar
AlphaTau
New Member
3 years ago
Solved

Sort years chronologically

I'm working on a dataset that has a country and a year columns. After doing the transformations in Power Query and loading to Power BI the sorting of the dataset in Data view is messed up. I would li...
  • grantsamborn's avatar
    3 years ago

    Hi AlphaTau 

    In PowerQuery, you can sort by multiple columns and create an index based on that sort.

    Try this in PowerQuery:

    1. Select the Country column and sort accordingly

    2. Right-click the next column (Year) and sort accordingly.

     

    At the far right of  the column headers next to the down arrow to select/sort, you should see a tiny "1" or "2" next to Country and Year respectively.

     

    3. Add a new Index column.

    4. After you are done in PowerQuery, the Index should be available to sort by.

     

    I hope this helps.