Hello all!
I have a excel like this below:
This table has to be
How is it possible? Can anyone help me ?
Hello all!
I have a excel like this below:
This table has to be
How is it possible? Can anyone help me ?
dt = dt.AsEnumerable.GroupBy(function(x) x("Number").ToString+x("Name").ToString).Where(function(x) x.Count=1).Select(function(x) x.First()).CopyToDataTable
cheers
Hi @Betul_Dundar ,
creates a new DataTable (uniqueRows
) with these filtered rows.
InputDataTable: Your Input DT
Assign: uniqueRows=
(From row In inputDataTable.AsEnumerable()Group By key = New With { Key .Value = row("ColumnA"), Key .Value2 = row("ColumnB")} Into Group Where Group.Count() = 1 Select Group(0)).CopyToDataTable()
Thanks,
Vinit Mhatre
You can simply use this query
distinctRows = (From row In inputDataTable.AsEnumerable()
Group row By number = row.Field(Of Integer)("Number") Into groupedRows
Select groupedRows.First()).CopyToDataTable()
you can try this as well
dt1.AsEnumerable.GroupBy(Function(a) Tuple.Create(a(0).ToString,a(1).ToString)).Where(Function(b) b.Count=1).SelectMany(Function(grp) grp).copytodatatable
Use below expression:
DT2.AsEnumerable().GroupBy(Function(row) New With { Key .Number = Int32.Parse(row.Field(Of String)(“A”)), Key .Name = row.Field(Of String)(“B”) }).Where(Function(Group) Group.Count().Equals(1)).SelectMany(Function(Group) Group).CopyToDataTable()
** Replace “A” & “B” with your Column Name or Column Index - Number & Name OR 0 & 1
Hope it will helps you
Cheers!!
Thank you it worked!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.