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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Reorder matrix columns and rows

Hi,  apologies if this has been posted, but I couldn't find it.

 

As you can see from the image below, my headers are in numerical/ alpahabetical order.  I would like to re-arrange them so they are in chronological order.  I have created another column which allocates them a number 1 to 5, so I can order them in some bar charts I have, but am unable to do this in a matrix.

Rickfear_0-1598339806647.png

 

1 ACCEPTED SOLUTION

@Anonymous
There is no way to tell the matrix what sort by to use for the columns - this is done automatically based on the column settings.

Now that you have created the column in Power Query, please select the Duration column from the Fields pane on the far right. NOTE: You must click on the text for Duration (do NOT tick or untick the box next to it).

When you selcect the Duration column, if you are using the latest version of Power BI, you will see a Column Tools tab appear in the ribbon as per the post by @FahranAhmed
Click the Column Tools tab, then select Sort By Column.

Note you should still have the Duration column selected, so choose PCSort2 from this list.

Wait for Power BI to update, then your matrix should automatically reorder the columns for you.

You can also remove PCSORT2 from the matrix as Duration will be using that column now to sort every time it is used in any visual (including column and bar charts)

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

8 REPLIES 8
AllisonKennedy
Super User
Super User

@Anonymous
It sounds like you know what to do - can you confirm that your column charts are working/sorting correctly? Sometimes I find that Power BI needs a reset, so try going to a different page and coming back, or try removing the column from the matrix and adding it back in.

If that still doesn't work, and you have used the "Sort by Column" button as per the link @amitchandak posted, then we will need to know more about how you have set up the matrix in order to help you and also would be helpful to see a screenshot of the column charts that are working so we can see how you have set those up in comparison.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

bar chart workingbar chart workingbar chart workingbar chart workingnew column added to sortnew column added to sortnot an option to sortnot an option to sort

Hi, I hope these images help.

Looks like you will get a circular reference error based on how you have done your Sort By column, so you either need to create that sort column in Power Query, or in the raw data. Then you will be able to click on the age column and in the Column Tools tab > Sort By Column and select the new column you created in Power Query.

TO create this in Power Query, just click Transform Data, then in the Add Column tab click Conditional and do similar to what you have done with DAX, but using Power Query.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

I have created a new column in power query, and have sorted.  Still not an option.

newcol.PNGstillnotthere.PNG

@Anonymous
There is no way to tell the matrix what sort by to use for the columns - this is done automatically based on the column settings.

Now that you have created the column in Power Query, please select the Duration column from the Fields pane on the far right. NOTE: You must click on the text for Duration (do NOT tick or untick the box next to it).

When you selcect the Duration column, if you are using the latest version of Power BI, you will see a Column Tools tab appear in the ribbon as per the post by @FahranAhmed
Click the Column Tools tab, then select Sort By Column.

Note you should still have the Duration column selected, so choose PCSort2 from this list.

Wait for Power BI to update, then your matrix should automatically reorder the columns for you.

You can also remove PCSORT2 from the matrix as Duration will be using that column now to sort every time it is used in any visual (including column and bar charts)

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Option avaiable on Top Ribbon under Column Tools.

 

When you will click on column in table then Column tools tab will appear

 

SortBy-2.png







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




FarhanAhmed
Community Champion
Community Champion

create a integer column in Power Query Editor ,

Assign numbers accoringly as per your sorting.

 

https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column#sort-using-the-sort-...

 

you will get the similar output.

SortAlphanumeric.png







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , hope you have marked that new column as the sort column for this column which you are using in rows and columns.

 

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

example

Sort Month.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.