37 - Removing duplicates ignores your sort order (Power Query)

Опубликовано: 31 Июль 2023
на канале: WesleySon
358
5

4 methods to remove duplicates while maintaining your sort order.
If you simply add a sorting step right before removing duplicates, that new sort order is ignored.

Method 1: Add a new column (e.g. 1 in each row) immediately before you sort. I don't know why it works (❁´◡`❁)
Method 2: Wrap the table in Table.Buffer before you remove duplicates. This loads the table into memory, which will possibly be slower
Method 3: Group By with adding a new column. Yeah, this method is a waste.
Method 4: Use Group By with Table.Max or Table.Min. This way you sort each individual mini-table, then grab the highest/smallest value. I don't know if this will be slower or faster - you're sorting each view (mini-table), but each view is also smaller.

I would use method 1 even though I don't know why it works, or method 2 if you want to reduce the number of steps.

00:00 - Intro
01:43 - Add a new column before sort
02:12 - Wrap table in Table.Buffer
03:24 - Group By (with a new column...)
05:52 - Group By & Table.Max
08:14 - Using Table.Repeat to time queries
09:28 - My preference (is method 1)