Forum Discussion
Remove duplicates based on sort in Power Query
- 7 years ago
I've run into this before. I think it's a result of query folding not operating in the order that you'd expect.
The workaround that worked for me was to add an index column after sorting before removing duplicates. This breaks query folding and forces it to operate in the order you just defined by your sort.
- 7 years ago
AlexisOlson Anonymous
Do check this video from curbal.com. It beautifully explains the reason why changing Sort Order in Power query doesn't work for removing duplicates and using Table.Buffer to keep new Sorting Order in memory.
Sharing this as it might be helpful in some other scenarios too..
I've run into this before. I think it's a result of query folding not operating in the order that you'd expect.
The workaround that worked for me was to add an index column after sorting before removing duplicates. This breaks query folding and forces it to operate in the order you just defined by your sort.
- Anonymous7 years agoNot applicable
Thanks Alexis! Worked perfectly.
- AnkitBI7 years agoSolution Sage
AlexisOlson Anonymous
Do check this video from curbal.com. It beautifully explains the reason why changing Sort Order in Power query doesn't work for removing duplicates and using Table.Buffer to keep new Sorting Order in memory.
Sharing this as it might be helpful in some other scenarios too..
- EduSurveys6 years agoAdvocate II
AnkitBI , are there advantages to using Table.Buffer versus using Index like AlexisOlson suggested? Index worked for me, but I wanted to know if there are cases where it won't.
Thanks!
- lrobb4 years agoFrequent Visitor
I need to remove duplicates based on keeping the second instance rather than the first, if I add an index and sort descending then remove duplicates should that work?
- AlexisOlson4 years agoSuper User
If there are always exactly two instances, this should work. Are there always at least two and no more than two?
- Anonymous4 years agoNot applicable
Worked perfectly!
- jhauff_RFO1 year agoAdvocate I
Pefect! Thanks for you help 😊.