Vigyata.AI
Is this your channel?

Power Query Remove Duplicates Keeps the WRONG Record

30.9K viewsยท 1,417 likesยท 8:28ยท Jun 11, 2026

๐Ÿ›๏ธ Products Mentioned (4)

๐Ÿ”ฅ Get our brandnew Power Query exercise pack (including the GroupBy method): https://www.xelplus.com/course/power-query-challenge-pack/ Remove duplicates in Power Query, sort by date, keep the latest record. Logical, right? On a large file it can quietly hand you the wrong number, and nothing breaks to tell you. That's the trap in this video. You sort newest-first, remove duplicates to keep the top row, and the result looks fine. Then you run it on a bigger dataset and the count is wrong. No error. No warning. Just bad data going into your report. The cause is lazy evaluation. Power Query tries to be efficient and skips the full sort before removing duplicates, so it keeps an older record instead of the most recent one. I'll show you exactly how to spot it, how to check your work against the source, and the one-line fix: wrapping your sort step in Table.Buffer() so the whole table sorts in memory first. There's also a second method using Group By that doesn't rely on sort order at all. I cover that one in our Power Query exercise pack. ๐Ÿ“‚ Get the practice workbook: https://www.xelplus.com/power-query-keep-latest-record/#download ๐Ÿ“˜ Master Excel Power Query (full course): https://www.xelplus.com/course/excel-power-query/ โฑ๏ธ Chapters 00:00 The "Remove Duplicates" Power Query Trap 00:31 The task: finding the latest stock count 02:28 The "logical" way (sort + remove duplicates) 04:10 Checking the result against the CSV 05:03 Why Power Query kept the wrong record 06:10 The fix: Table.Buffer 07:41 A second method: Group By ๐Ÿ“จ Subscribe to "Between the Sheets" newsletter to stay on top of office tips and Excel hacks: https://link.xelplus.com/yt-d-newsletter ๐Ÿ”“ Join this channel to get access to perks: https://www.youtube.com/channel/UCJtUOos_MwJa_Ewii-R3cJA/join ๐ŸŽฌ LINKS to related videos: Learn to Automate Everything with Power Query: https://youtu.be/x7mzOYEn0XA You WON'T BELIEVE These 10 HIDDEN Features in Power Query: https://youtu.be/8hjgmJk5RiA ๐Ÿ“ฒ Letโ€™s connect on social: LinkedIn Leila: www.linkedin.com/in/leilagharani LinkedIn XelPlus: https://www.linkedin.com/company/xelplus Instagram: https://www.instagram.com/lgharani #Excel #powerquery

๐ŸŽฌ More from Leila Gharani