Forum Discussion
preserve order when using Table.Group
As documented, Table.Group "cannot guarantee to return a fixed order of rows". While this is bad for sorted data when used with Text.Combine. For example, the following is sorted by Time first and I would like to group by Id while Combine Text in order.
| Id | Time | Text |
| 1 | 12:00 | abc |
| 1 | 13:00 | def |
| 2 | 14:00 | ghi |
Another approach would be to create a new column with Time and Text as Table first, then save it as list when grouping, and finally reorder the list according to Time. But it is too complex.
Any ideas? Thanks~
You can try GroupKind.Local - to my understanding, it should keep the sort order (but you can only use it if your data is in a consecutive order: https://blog.crossjoin.co.uk/2014/01/03/aggregating-by-local-groups-in-power-query/
4 Replies
- Greg_DecklerCommunity Champion
If it is complex M, then it's ImkeF
- ImkeFCommunity Champion
You can try GroupKind.Local - to my understanding, it should keep the sort order (but you can only use it if your data is in a consecutive order: https://blog.crossjoin.co.uk/2014/01/03/aggregating-by-local-groups-in-power-query/
- xieofxieFrequent Visitor
Thanks~ But how could we make sure of that (keep order)? I didn't find any document about GroupKind.Local.