Murat
(Murat)
October 1, 2024, 11:36am
1
Hi,
I have this data. How can I obtain like this.
Arrival and Departure are unique. Below code works for “Arrival” column I want to add Departure column too.
data.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(“Arrival”)).Select(Function(c) c.First).CopyToDataTable()
lrtetala
(Lakshman Reddy)
October 1, 2024, 11:48am
2
Hi @Murat
Can you try the below query
DT = DT.DefaultView.ToTable(True, "Arrival", "Departure")
Regards,
1 Like
Hi @Murat ,
To create a DataTable that contains unique rows based on both the “Arrival” and “Departure” columns using LINQ
dt_old.AsEnumerable() _
.GroupBy(Function(row) New With {Key .Arrival = row.Field(Of String)(“Arrival”), Key .Departure = row.Field(Of String)(“Departure”)}) _
.Select(Function(g) g.First()).CopyToDataTable()
Regards,
Sneha
1 Like
sudster
(Sudster)
October 1, 2024, 12:40pm
4
If there’s only 2 columns, wouldn’t a simple Remove Duplicate Rows activity in Programming → DataTable work?
Anil_G
(Anil Gorthi)
October 1, 2024, 1:09pm
5
@Murat
The same cna be extended
data.AsEnumerable().GroupBy(Function(a) a("Arrival").ToString + a("Departure").ToString).Select(Function(c) c.First).CopyToDataTable()
also as mentioned above if only two columns then use remove duplicate rows
cheers
1 Like
system
(system)
Closed
October 4, 2024, 1:10pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.