Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi community, @edhans & @v-lili6-msft
Recently @edhans gave me M code to get a table that i needed;
https://community.powerbi.com/t5/Desktop/How-can-I-create-this-table-or-matrix/m-p/1196273#M535699
But now, i need a little bit more help to adapt M to sort first by Pallet Pcs, and then by Pallet Id.
Just like the @v-lili6-msft helped me to adapt the measure;
https://community.powerbi.com/t5/Desktop/Double-Sort-or-Sort-into-another-previous-Sort/m-p/1200991
How can i do this?
To sort first by Pallet Pcs and then, by Pallet ID, to bring less pallets... But into the M code.
I hope you can help me again...
Hi @Anonymous ,
If you want to sort in M code, you could just click corresponding columns(click Pallet Pcs first, then click Pallet Id ) to set sort by.
But I think sort in M code will change when you put data in visual, so I suggest you could set sort in visual. If you want to set double sort, you could click corresponding column headers. You could refer to power-bi-desktop-march-2020-feature-summary(Multi-column sort for tables) for details.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @dax,
The thing is that i need to sort previously to get the table, becuase it double sort will bring me less pallets,
Let me explain with an example...
Table A;
| tem | Request | OnSite Pcs | OffSite Pcs | Pcs to complete request |
| 609048-109-10 | 120 | 20 | 160 | 100 |
Table B;
| Item | Pallet ID | Pallet Pcs |
| 609048-109-10 | 7 | 10 |
| 609048-109-10 | 10 | 40 |
| 609048-109-10 | 12 | 20 |
| 609048-109-10 | 13 | 20 |
| 609048-109-10 | 9 | 20 |
| 609048-109-10 | 11 | 40 |
| 609048-109-10 | 8 | 10 |
M will bring me the pallets 7, 8, 9, 10 and 11 because this pallets, in order to the sort by Pallet ID, sum 120 pcs to complete the 100 requested. Right?
But, If i sort first by Pallet Pcs, and then by Pallet ID in M, like the edited the Measure, (Something like the next table).
| m | Pallet ID | Pallet Pcs |
| 609048-109-10 | 10 | 40 |
| 609048-109-10 | 11 | 40 |
| 609048-109-10 | 9 | 20 |
| 609048-109-10 | 12 | 20 |
| 609048-109-10 | 13 | 20 |
| 609048-109-10 | 7 | 10 |
| 609048-109-10 | 8 | 10 |
The result table return me only the Pallets 10, 11 & 9, this pallets sum 100 pcs.
That's what I need, edit M like the edited measure with the doule sort to bring less pallets.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 50 | |
| 43 |