DT.DefaultView.ToTable(True,“First Column Name”,“Fourth Column Name”).Rows.Count
This will get the unique pair rows count for the First two Columns in the Datatable.
I need to get the duplicate pair of rows.
Could anyone help me here??
DT.DefaultView.ToTable(True,“First Column Name”,“Fourth Column Name”).Rows.Count
This will get the unique pair rows count for the First two Columns in the Datatable.
I need to get the duplicate pair of rows.
Could anyone help me here??
You want count or what
@rlgandu I need to get the duplicate pairs and write in “sheet2”
Hi @Oozair_Khan
Try the below syntax. In the mean while, you can send the input.
DT.AsEnumerable().GroupBy(Function(row) New With { Key .Column1 = row.Field(Of String)("First Column Name"), Key .Column2 = row.Field(Of String)("Fourth Column Name") }).Where(Function(g) g.Count() > 1).SelectMany(Function(g) g).CopyToDataTable()
Regards
Hey @Oozair_Khan
try this solution:
Dim duplicates = DT.AsEnumerable().
GroupBy(Function(row) New With {
Key .FirstColumn = row("First Column Name").ToString(),
Key .FourthColumn = row("Fourth Column Name").ToString()
}).
Where(Function(group) group.Count() > 1).
SelectMany(Function(group) group.ToList()).CopyToDataTable()
DT=DT.AsEnumerable().GroupBy(Function(x) New With {
Key .Column1 = x.Field(Of String)("First Column Name"),
Key .Column2 = x.Field(Of String)("Fourth Column Name")
}).Where(Function(g) g.Count() > 1).SelectMany(Function(g) g.Skip(1)).CopyToDataTable()
Hi @Oozair_Khan
→ Read Range Workbook
Output->dt
→ Use below syntax in Assign:
- Assign-> dt= dt.AsEnumerable().GroupBy(Function(row) New With { Key .Column1 = row.Field(Of String)("Name"), Key .Column2 = row.Field(Of String)("Color") }).Where(Function(g) g.Count() > 1).SelectMany(Function(g) g).CopyToDataTable()
→ Write Range Worbook
Regards
Try this…this will give count of rows where there duplicates alone
Countvar =Dt.AsEnumerable.GroupBy(function(x) x("Col1").ToString+x("Col2").ToString).where(function(x) x.count>1).Count
Cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.