Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
v4anand18
Advocate I
Advocate I

Sorting a table using multiple columns

Hi All,

 

 

Is it possible to sort a table using multiple columns?

 

 Revenue tableRevenue table

 

My table looks like this and i would like to sort by "Year" first and then by "Month". Is it possible?

1 ACCEPTED SOLUTION
StevePBennett
Advocate I
Advocate I

I see this tread is quite old, but sorting a visual by one column and then a second column is as simple as clicking the 1st column header to sort ascending or decending. Then simply hold the <Shift> key down and click on the header of the second column.
Of course you can just keep the <Shift> pressed and click on a 3rd, 4th etc until happy. 

I hope this helps. 
Steve B

View solution in original post

29 REPLIES 29

Hi,

I am trying to apply this step in my query editor as a step, but it throws an error. Could you please suggest how to resolve it.

Expression.Error: The name 'Changed Type' wasn't recognized.  Make sure it's spelled correctly.

 

Thank you,

Roopali

Hi @roopsnegi,

There is a break in your steps present in the Query Editor.

 

Check if all the steps are properly linked to each other. In simple words, there is a problem (mostly name related) with the steps before, in or after the Changed Type Step. 

 

If you post the M-Query of your query, it will be easy to solve this error....

The m code you’ve mentioned solve the problem to sort on the matrix visual? Would you post an example with repeated names? Cheers!
Thejeswar
Community Champion
Community Champion

@v4anand18,

Yes it is possible, but not from the visual side

 

You will have to do all the sorting based on multiple columns in the Power Query and then build you visual using the table.

 

If you have already built a visual, changing the sorting now might not show the proper sorting. In such case you will have to re-create the visual from scratch

 

Here's how the M code will look once you sort in Power Query

 

= Table.Sort(#"Changed Type",{{"Team", Order.Ascending}, {"Plan", Order.Descending}})

You can see from the below image that inspite of not applying sorting in the visual, due to the sorting at power Query, my data looks sorted as expected

 

i.e. In the Visual Team is sorted in Ascending Order and then Plan is getting sorted in descending order with in each Team.

 

sort.PNG

 

 

 

You can sort multiple columns in a table just by holding the shif key and clicking the column  headers you want to sort.

Hello,

I successfully edited M code in the query to sort how I would like, but after closing and applying the sort is not how I intended. I tried sorting the column by itself (default), but no success.

 

Suggestions?

 

Thank you,

Hi there,

 

This was helpful; however, when I exit out of power query and refresh the original data does not reflect the sorted values. Any thoughts on how to change that?

saf
Regular Visitor

Same problem... sorting ok in power query, but not in visual side...

You might need to sort by column but not into power query

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.