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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
diana66
Helper I
Helper I

Change columns order in Matrix

Hello,

 

I have the following matrix and I want a specific column order:

 

p7.PNG

 

For the Colum "Market" where I have the Stores, I want them in a specific order. Could you, please, tell me how can I do that?

 

Thank you!

 

 

1 ACCEPTED SOLUTION

It is going to depend on your data. But, if you have a table in which you have your values for your store identifiers, Store 1, Store 2, Store 3, etc., in Power Query createa a column that looks at those values and produces your sort order, let's say you want:

 

Store 2

Store 4

Store 3

Store 1

 

You would create a column, we will call this column "Sort", where if your Store column is Store 2, this column would be 1 and if the Store column is Store 4, 2 and so on.

 

Then, once you import this data, you would select your Store column. You would go to Column Tools and then Sort by column and choose your new Sort column.

 

Not sure I can explain the process any better than that.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

You will need to create a Sort By column that has the ordering that you want and then sort your column by that. In the new ribbon, the Sorty By is in the contextual Column Tools area and is called "Sort by column".



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

Thank you for your reply. I'm afraid I didn't understand very well how I should do it 😄

It is going to depend on your data. But, if you have a table in which you have your values for your store identifiers, Store 1, Store 2, Store 3, etc., in Power Query createa a column that looks at those values and produces your sort order, let's say you want:

 

Store 2

Store 4

Store 3

Store 1

 

You would create a column, we will call this column "Sort", where if your Store column is Store 2, this column would be 1 and if the Store column is Store 4, 2 and so on.

 

Then, once you import this data, you would select your Store column. You would go to Column Tools and then Sort by column and choose your new Sort column.

 

Not sure I can explain the process any better than that.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Thank you so much for the reply! It worked.

Just one more question: I had the column which I sorted by the new Sort column, in a dax formula with ALLEXCEPT(that column), and now the formula is not working. Should I replace with the new Sort column in the formula instead of the old column? 😄

I don't know, that sounds very odd. What does the formula look like that is not working?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Here I had instead of 'Sort', a column named market which is the column where I have the Store names (Store 1, Store 2, etc)

 

p8.PNG

 

I created the Sort Column with values for each store depending on my preferences, and in the Matrix table I sorted the Market column by the Sort column. 

 

 

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors