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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hejszyszkiiii
New Member

Matrix Sorting Columns

Hello,

I am having matrix table within power bi that :

Has Year-Quarter as columns,

Country, Property as row,

Two measures as a value.


The problem I have is that the values are represented like below:

Q1 KPI, Q1 KPI2, Q2 KPI, Q2 KPI2 (and so on)

What I would like to achieve is like below:

Q1 KPI, Q2 KPI, Q1 KPI2, Q2 KPI2.

Anyone has an idea how to achieve that?

Thanks in advance!

2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @hejszyszkiiii,

 

Can you please try this approach:

SortingTable = 
DATATABLE(
    "Quarter", STRING,
    "KPI Order", INTEGER,
    {
        {"Q1 KPI", 1},
        {"Q2 KPI", 2},
        {"Q3 KPI", 3},
        {"Q4 KPI", 4},
        {"Q1 KPI2", 5},
        {"Q2 KPI2", 6},
        {"Q3 KPI2", 7},
        {"Q4 KPI2", 8}
    }
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

BIswajit_Das
Super User
Super User

Hello @hejszyszkiiii 
In a matrix Visual if you want to sort a column you can do it this way;
For example;

let's be the demo table with column

data
Q1 KPI
Q1KPI2
Q2 KPI
Q2KPI2

Now inorder to get the order right you have to create an another Order column like

data ORDER
Q1 KPI 1
Q1KPI2 3
Q2 KPI 2
Q2KPI2 4

 

then you can sort the column as per the order column like mentioned below

Initially
s1.png

 

After sorting the column with Order column
s2.png

 

Thanks & Regards...

View solution in original post

3 REPLIES 3
ACS_BIM
Regular Visitor

I have read and tried just about every option in the forums for sorting the column headers in a Matrix visual in Power Bi. Not one has been successful, so let me try to explain as I am sure I am missing something.

I connected to our SQL database and used the "Import" option then selected the tables I needed. Verified relationships.

I have built a report and used the OOTB Matric visual all the data is showing what I need in the visual 

The column headers are coming from one data point in one of the tables.  No matter  what I do they are showing left to right alphabetically.  I need to reorder the columns to a specific order.

Table column headers by default:

Columns.jpg

I need these to appear from left to right per the following order:

  1. Connection Location
  2. Connection Type
  3. Connection Size
  4. Pressure
  5. Flow
  6. Temperature
  7. Amps
  8. Breaker
  9. Voltage
  10. Phase
  11. Notes

I tried adding a column to the table, set it to "Sort" but have yet to figure out teh DAX expression to accomplish this.

I added a table with a sort order and mapped the relationship - but to no avail.

Some have said, you can drag a column header left or right to reorder - to no avail.

Is the issue because it is coming from a connected database?

Is this simply not possible (which would seem odd)?

 

Please help!!

BIswajit_Das
Super User
Super User

Hello @hejszyszkiiii 
In a matrix Visual if you want to sort a column you can do it this way;
For example;

let's be the demo table with column

data
Q1 KPI
Q1KPI2
Q2 KPI
Q2KPI2

Now inorder to get the order right you have to create an another Order column like

data ORDER
Q1 KPI 1
Q1KPI2 3
Q2 KPI 2
Q2KPI2 4

 

then you can sort the column as per the order column like mentioned below

Initially
s1.png

 

After sorting the column with Order column
s2.png

 

Thanks & Regards...

Sahir_Maharaj
Super User
Super User

Hello @hejszyszkiiii,

 

Can you please try this approach:

SortingTable = 
DATATABLE(
    "Quarter", STRING,
    "KPI Order", INTEGER,
    {
        {"Q1 KPI", 1},
        {"Q2 KPI", 2},
        {"Q3 KPI", 3},
        {"Q4 KPI", 4},
        {"Q1 KPI2", 5},
        {"Q2 KPI2", 6},
        {"Q3 KPI2", 7},
        {"Q4 KPI2", 8}
    }
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors