Remove Duplicate RowItem without changing rowindex Values

Order Code Description Transaction ID
99845 ghhg7 7655990123
99845 ggd6md 7765398767
67902 vfdd76 98570908
56789 b757g 2265689683
56789 nv59b 75648676
78905 m,5743 896464767
89056 xddg34 86588663

Hi,

Can anyone please suggest how to compare the duplicate rows in Datatable(inputDT)and Remove Duplicate Row item looping through each row and comparing each row using Filter Datatable activity.
i need out put like this:

Order Code Description Transaction ID
99845 ghhg7 7655990123
ggd6md 7765398767
67902 vfdd76 98570908
56789 b757g 2265689683
nv59b 75648676
78905 m,5743 896464767
89056 xddg34 86588663

Wothout Changing any row index

Hi @Krishna_Arjun

Try this:

uniqueDT = (From row In dt.AsEnumerable()
            Group row By key = New With {
                .OrderCode = row.Field(Of String)("Order Code"),
                .Description = row.Field(Of String)("Description"),
                .TransactionID = row.Field(Of String)("Transaction ID")
            } Into Group
            Select Group.First()).CopyToDataTable()

uniqueDT is of DataType System.Data.DataTable

Hope it helps!!

@Krishna_Arjun

check the reference

@Krishna_Arjun

Assign activity:
distinctRows = inputDT.AsEnumerable().Distinct(DataRowComparer.Default).CopyToDataTable()

Output DataTable:
distinctRows

No It’s not working same data will come output

Hi @Krishna_Arjun

Please try this

Dim previousOrderCode As Object = Nothing

For Each row As DataRow In dataTable.Rows
    If previousOrderCode IsNot Nothing AndAlso row("Order Code").Equals(previousOrderCode) Then
        row("Order Code") = DBNull.Value
    Else
        previousOrderCode = row("Order Code")
    End If
Next

Input:

image

Output:

image

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.