Forum Discussion
Does Table.Distinct guarantee it respects order?
- 5 years ago
There is no official statement from MS on this. The URL Greg_Deckler provided is accurate, but if you 100% need to know for a fact that is what happens, you will need to:
- Sort your data as desired.
- Group by the desired records
- Add an index
- expand the records
- Keep the first one (or last one, or whatever)
At that point there is no need to run Table.Distinct.
Note that Table.Distinct over an entire table this won't matter, but if you are using the optional columns, then it will.
Table.Distinct(Source) - won't matter
Table.Distinct(Source, {"Column1"}) - will matter
There is no official statement from MS on this. The URL Greg_Deckler provided is accurate, but if you 100% need to know for a fact that is what happens, you will need to:
- Sort your data as desired.
- Group by the desired records
- Add an index
- expand the records
- Keep the first one (or last one, or whatever)
At that point there is no need to run Table.Distinct.
Note that Table.Distinct over an entire table this won't matter, but if you are using the optional columns, then it will.
Table.Distinct(Source) - won't matter
Table.Distinct(Source, {"Column1"}) - will matter
Thank you Greg and Edhans both.