Forum Discussion
Sort grouped row by created on date in Order Ascending
The Table.Group() does not preserve sort order or defines a sort order. So if you want your groups to be sorted, you do it AFTER the sort, but on each group individually.
Do the following just after your group by (check the step and field names first!):
= Table.TransformColumns(#"Grouped Rows",{{"Notes", each Table.Sort(_, {{"Latest Date", Order.Descending}})}})
I have added that command and I am now getting the following error.
- PwerQueryKees1 year ago
Super User
Can you share all the M Code. I want to see how you create the "Combined Notes" column. It is probaly after that step where you need to do the sort.
- phull5431 year agoFrequent Visitor
Ok, I have included it below. Let me know if you need anything else.
- PwerQueryKees1 year ago
Super User
Correction. I now see that you get 2 different Notes fields, each sorted the way you want. My apologies, I reacted to quick.
Unless you created those yourself, I would stick with the solution AntrikshSharma has provided.
If you did create those yourself, you can consider to keep the Notes as indidual rows in the table created by the group by. Then do a Table.Combine() on the 2 tables (on each row) en sort that table.So, something like = Table.Sort(Table.Combine({Note_Table1, Notes_Table2), {{"Latest Date", Order.Descending}} in a Table.AddColumn()