Forum Discussion
Power Query: Group By function ignore previous sorting
- 8 years ago
One should always bear in mind that there may be a huge difference between the code steps and the way those code steps are actually evaluated when Power Query executes a query.
Your issue is similar to first sorting a table and next remove duplicates (Table.Distinct): it may be that not the first record will be kept.
Also the solution seems to be similar: buffer the table after sorting (and before grouping).
This will give you the expected results:= Table.Buffer(Table.Sort(Source,{{"date", Order.Ascending}}))
One should always bear in mind that there may be a huge difference between the code steps and the way those code steps are actually evaluated when Power Query executes a query.
Your issue is similar to first sorting a table and next remove duplicates (Table.Distinct): it may be that not the first record will be kept.
Also the solution seems to be similar: buffer the table after sorting (and before grouping).
This will give you the expected results:
= Table.Buffer(Table.Sort(Source,{{"date", Order.Ascending}}))Thank you for your response. I did find this workaround yesterday but:
1) is there a consequence in term of performances when dealing large amount of data (why is this not the default behaviour)
2) is there other cases when we should buffer the table (for instance when using Table.Distinct like you said in your post)
Thanks,
David