I have a dataset with daily COVID-19 data for the countries of the Americas since the beginning of the pandemic. I have many duplicated records (same ISO3_CODE and Report_Date) and I want to keep the most recent record for each. Ideally, I would like to this with ModelBuilder, if possible.
I tried DELETE IDENTICAL tool, but unfortunately it keeps the first duplicate and deletes the others. I want the exact opposite: Keep the last duplicate (MAX Object ID) and delete the previous ones.
Any suggestions?
Solved! Go to Solution.
I hope you have used the Sort Geoprocessing tool.
After sorting the features in descending order of ObjectID, the latest feature should be having the lowest ObjectID in the newly created feature class.
That was my idea.
First, you could Sort by ObjectID field in descending. Then try doing a Delete Identical.
You could add them in a Model Builder, and create a model.
Unfortunately, that didn't work. It still keeps the lowest (MIN) ObjectID.
I hope you have used the Sort Geoprocessing tool.
After sorting the features in descending order of ObjectID, the latest feature should be having the lowest ObjectID in the newly created feature class.
That was my idea.
Thanks for tip.
However, I'm still having issue deleting the duplicates.
SORT can't use ObjectID as sorting field. I had to ADD FIELD (ObjID), then assign it ObjectID value. After that, I was able to SORT using ObjID. However, when using DELETE IDENTICAL on the sorted feature layer, it deletes the rows from the sorted table, not the feature layer itself...
Is there an efficient way to apply the sorting to the original feature layer?
Join it back to original. Delete records that don't match.
It finally worked! Thank you Felix and Jayanta