Hello,
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.
Thanks.
Brett
ppr
(Peter Preuss)
November 2, 2021, 6:18pm
2
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.
Introduction
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:
[grafik]
A possible scenario could be:
Create a report containing following information:
the region code
the sum of CaseCount per RegionCode
t…
Whenever to implement any of the solutions that have a GroupBy function, I get this:
How do I fix this?
Thanks.
ppr
(Peter Preuss)
November 3, 2021, 3:31pm
4
give a try on the query syntax:
dtOutput =
(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!
ppr
(Peter Preuss)
November 3, 2021, 4:49pm
10
So please do it and give us feedback if the issue is resolved. Thanks
system
(system)
Closed
November 6, 2021, 4:49pm
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.