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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shaunwilks
Helper V
Helper V

Matrix Sorting by First Level Then Second Level

I have a scenario I thought would be easily catered for but it appears it would not.

 

I am using Matrix when has two levels. 

 

For simplicity sake lets say the levels are 

1. Transaction Header (Say the total amount of an Invoice) First Field is the "Invoice Reference Number"

2. Transaction Lines (Each of the Items sold on that Invoice) - Second Field is the "Item Code" (That I want sorted by Item Category - Not in alpha)

 

The measures may be something like Qty, Price, Tax and Net Value

 

In the table Id like the lastest Invoices shown at the top.

Therefore I highlight the "Invoice Reference" field and Sort by Column "Trans Date" and in the martix I sort by this field and set it to Descending so I get the latest invoices to the top. Tick.

 

Now within the the next level I want to show the line in Item Code order.

I highlight the Item Code Field and want to sort by the category. I can try the sort by column but it wouldnt apply in my matrix anyway.

 

As the Visual only allows the setting of order by a single field how can I manipulate the order of the fields at the Transaction line level to show in a specific order ??

 

I have tried numerous combinations and eitehr get told I cant sort the Item Codes by the field I add to set their order in the data using "Sort by Column"

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @shaunwilks 

You have two levels in the row field like

Capture14.JPG

You want to sort by level 1, then sort by level 2, right?

If so, refer to the links below:

https://community.powerbi.com/t5/Desktop/Sorting-a-matrix-second-level-sort-by-column-not-working/td...

https://community.powerbi.com/t5/Desktop/Two-level-sorting-Matrix/td-p/507259

 

Best Regards
Maggie

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.