I’ve seen many versions of solutions out there for this, but all appear to be overly complicated for what I need.
I have an excel file of addresses with columns “Address”, “City”, State", “Zip”, “Date”.
I want to delete all duplicates within column “Address” keeping the one with the most recent “Date”.
I’ve done the following and got it to work, but it’s looking for complete duplicate rows across all columns which isn’t what I need.
Any suggestions would be very helpful.
What had you seen so far. We can achieve it e.g. with a Grouping the data (Non LINQ / LINQ approaches) and processing the the group memebrs (Filtering to the most recent date in your case)
Have a look here:
This HowTo introduces on the different options for grouping data from a datatable in order to process the grouped data.
Grouping data and processing the grouped data is a common scenario e.g. when the grouped data is to aggregate like summing up, find maximum, get the average or concatening items.
Lets have a look on following data:
A possible scenario could be:
Create a report containing following information:
the region code
the sum of CaseCount per RegionCode
Whenever to implement any of the solutions that have a GroupBy function, I get this:
How do I fix this?
give a try on the query syntax:
(From d in dtInput.AsEnumerable
Group d by k=d("Adress").toString.Trim into grp=Group
Select r = grp.First()).CopyToDataTable
Similar error which I’ve seen before in my trials thus far: GroupBy not accessible in this context.
I didn’t have the System.Linq nor System.Linq.Expressions namespaces imported. Thanks!
So please do it and give us feedback if the issue is resolved. Thanks
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.