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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

28 REPLIES 28
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

Amazing and simple. Thanks!

How about a bar graph? I guess this works only for a table..

Thanks!!!!

Thanks @StevePBennett 

This really help 🙂 

Someone give Steve B some love over here because THIS IS THE ANSWER IN JUNE 2022, PEOPLE!

This is THE REAL ANSWER we need.  Thank you for sharing this!  I didn't like the accepted answer from 2018, so I'm glad I kept reading down the thread.

Doyin
New Member

Hi all! Is it possible to sort a table by multiple columns using "contain" in Power Query?

Hi @Doyin , use expression like this

= Table.Sort(#"Previous Step",{{"Column1", Order.Ascending}, {"Column2", Order.Ascending}})

 

Well, actually, this answer, wouldn't it be useful in Power Query instead of the question? I don't mean to be rude, but I'm new and I don't know how to apply the answer in the question. Thanks in advance.

roselilly23
Advocate V
Advocate V

As of March 2020 it is now possible from the visual side by using shift+click on the column headers. For more info: https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-march-2020-feature-summary/#_Multi-column_...

@roselilly23 , Finally I get your post in the thread. That is great!
@v4anand18 , I think you should mark as solution the @roselilly23 's post

Well noted @roselilly23 , and OMG thank god - finally!!!!

micwebnet
Employee
Employee

Provided accepted solution is incorrect. It only sorts PQ table and doesn't affect the visual. You'll need to add an Index column after the multi-column PQ sort and then sort your table on that column in PBI Desktop. Here's a video on how to do it: https://www.youtube.com/watch?v=RHhITmZjuDA.

 

Best,  Michael

Anonymous
Not applicable

Coming from a Tableau environment, I don't understand why this functionality doesnt exist in this tool. 

 

Sorting by mulitple columns is very basic stuff in Excel. 

 

Sorting within Power Query is not a good solution; a different VIZ, using the same data, might require a different sort.  

 

 

Arklur
Resolver II
Resolver II

The "Accepted Solution" is definitely wrong. With that sample data, even if you don't specify an order in Power Query, the result is the same:

0FGIOOl

And no matter what sort order you specify in it, it will stay the same. In a table visual data will be sorted from left to right. In this case Team > Country > Plan > Actual. If you sort by a specific column, then - I think - the sort order will be "Selected Column" then from left to right. If you want to sort a table by multiple columns, the only option you have is to have a concatenated column with the necessary columns and specify the sort order on that column, which is obviously not a nice workaround, but might work in some cases.

 

Likely you can verify this using DAX Studio and check the executed query behind the curtains.

Anonymous
Not applicable

Hello,

 

I found this thread and am doing somethign similar. I am using this method with the M code, and it works perfectly. I am tryign to now get the table to display as the data in the query does, but cannot figure out why it is sorting columns alphabeticlly and not following the source sorting?

 

New to Power Bi, so would need simple or easy to follow help.

 

Thank you, 

v-jiascu-msft
Employee
Employee

Hi @v4anand18,

 


Can you mark the proper answer as a solution please?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi 

 

 

 

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.