Eliminating duplicate rows by comparing values in different cells

Hi all,

as part of my workflow, I merged 4 different datatables into one single datatable. There could be duplicate rows in the merged datatable. Sample screenshot is below.
The order number will be populated in one and not the other between the duplicated rows. The client dispute id, invoice number and disputed amount are the common values between each set of duplicated rows.
my requirement is if client dispute id, invoice number and dispute amount are the same between any two rows, the one that doesn’t have the order number must be deleted.
I am not sure how to go about this scenario. can anyone suggest ways to go about doing this.

image

Thank you,
pari

@parimala.prata, hey man, is there a reason why you did not compare the data tables before you merge them together?

The data is not redundant within the data tables themselves. When i combine all datatables together, the duplicity occurs.

Also, i was thinking if there is a way to identify the duplicates under the invoice number column and remove that row. this could also work for my scenario.

@parimala.prata
Have a Look Here
Linq query to identify duplicates and delete both entries

And Here

hi,
I tried the third scenario where it will keep all rows and remove the first duplicate. Getting an error. Do i have to install any packages?

thank you,
pari

Nö additional package IS needed. Linq should be in the imporzed namespace. But in such a Case Always refer to running Demo.
From d in dt.asenunerable is needed

it was my fault. didn’t include a opening bracket. this time i am getting another error.

image

@parimala.prata
As in the running Demo the used variable is of datatype Datatable IT has the Method asenumerable

The Same IS required in your Implementation. In Case of there is an issue with Import of the datasetextensions into the namespaces have a Look Here

2 Likes

Hello ppr,

thank you for your assistance. I had to add the assembly reference to fix the issue. The initial piece of code you provided worked like a charm.

This community is awesome…Lots of experts actively engaging on the forum and helping people resolve their issues. Also the trove of knowledge that is shared through the forms is awesome. Extremely helpful.

Thank You,
pari

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