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}}))Thanks for the information, I was looking for a logical issue in my code.
Nice solution, easy to understand and to the point.