Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Removing duplicates based on Date

I am facing an issue with how i am removing the duplicates from the below set of data in Power Query 

 

What i am trying to do is pick the last price change transaction from a set of data. In the below set, i want the "10004-7/26/2021 2:31:23 PM" to be picked. I tried to sort on key data & time and then removed duplicates on Goods ID and Date. But, for some reason i always ended up with the transaction with an earlier time stamp "10004-7/26/2021 2:12:49 PM"

 

Any better way to resolve this? 1 goodsId can have multiple price change in a day. need to pick the latest price change for that day. 

This works fine when i try to take this below 4 into a table and sort and remove duplicates. But with a bigger dataset behaves different. 

 

ChangeIdGoods IddtDateGoods ID and DateKey date & time
326330100047/26/2021 14:1210004-2021-07-2610004-7/26/2021 2:12:49 PM
326345100047/26/2021 14:3110004-2021-07-2610004-7/26/2021 2:31:23 PM
328262100047/30/2021 14:0710004-2021-07-3010004-7/30/2021 2:07:38 PM
331467100048/10/2021 15:2610004-2021-08-1010004-8/10/2021 3:26:56 PM
  • Anonymous , Create s separate data column

    date only = DateTime.Date([Date])

     

    And the use group by and take max on of the columns that are not needed in group by

2 Replies

  • Anonymous , Create s separate data column

    date only = DateTime.Date([Date])

     

    And the use group by and take max on of the columns that are not needed in group by