Remove Duplicate rows of having duplicate data in 2 Columns in which 3rd Column status is Completed and Non-Completed using Linq

Remove Duplicate rows of having duplicate data in 2 Columns in which 3rd Column status is Completed and not Completed using Linq in the bulk of data

@Shubham_Arora1

Can you share a sample input and expected output

image

Here @Shiva_Nikhil :- You Can see the Input file of 10000 records having 3 columns Name , Subject ,Result having 2 Duplicate Columns Data in which Result Column is Completed and another is Non-Completed. Wants the DataTable through Linq in which there should be no Record of Completed and also Duplicate of 2 Column row which has Completed Result as well Non-Completed that should be removed from dataTable.

Currently we could cleanse on only group count = 1 by

dtCleansed =

(From d in dtData.AsEnumerable
Group d by k1=d("Name").toString.Trim, k2=d("Subject").toString.Trim into grp=Group
Where grp.Count = 1
Select r = grp.First()).CopyToDatable

But as you can see in the code we had no logic for Complete presence check included, as we do not see it clearly defined within the description (e.g. do it, handle alternate case like multiple group members, but no completed)

Also have a look here:

@ppr , i wants on the basis of Result Column to discard the Completed one Status row and also those rows which had completed as well non-completed status Rows on the basis of Duplicacy of Name and Subject Column.

we do feel, that we can adapt the LINQ. But as mentioned, we do see some undefined requirements

Also have a look at this modified LINQ

dtCleansed =

(From d in dtData.AsEnumerable()
Group d by k1=d("Name").toString.Trim, k2=d("Subject").toString.Trim into grp=Group
Let cntsCompleted = grp.Any(Function (c) c("Result").ToString.ToUpper.Contains("COMPLETED"))
Where not cntsCompleted 
From g in grp
Select r = g).CopyToDataTable

Just let us know, where the result from given LINQ is different from the expected output.

@kumar.varun2 can you help for this insight

we had corrected a typo

input:
grafik

Flow
grafik

Output:
grafik

So,