cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
AlphaTau
New Member

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 like to sort the data by country and then by year.

 

AlphaTau_0-1682889142938.png

 

But for some reasons I cannot sort by two columns.

Is there anything I can do?

Is sorting the table in Dataview affects the visuals? Because when I make the line chart the years are not in chronological order

 

AlphaTau_1-1682889247523.png

Please help.

1 ACCEPTED SOLUTION
grantsamborn
Solution Sage
Solution Sage

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.

 

View solution in original post

1 REPLY 1
grantsamborn
Solution Sage
Solution Sage

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.

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors