How to use LINQ different data table

pls help i have 2 file excel, i need to check 2 condition :

  1. if on file aaa column “KE 1” has “Passed” value and on file bbb has more than 70%, than write “Passed” on column “KE 2” in aaa file
  2. if on file aaa column “KE 1” has “Passed” value and on file bbb has less than 70%, than write “Error” on column “KE 2” in aaa file

i have tried with this, but still not working

for each on aaa file, then

(From i In Enumerable.Range(0,bbb.Rows.Count)
Let r = bbb.Rows(i)
Where row(“KE 1”).toString.Equals(“Passed”) And Convert.ToDecimal(r(“Compliance”)) >= 0.70
Select i).DefaultIfEmpty(-1).First


How about the following?

dta.AsEnumerable.Zip(dtb.AsEnumerable,Function(a,b) dta.Clone.LoadDataRow({a(0),a(1),if(a("KE1").ToString="Error" OrElse Convert.ToDecimal(b("Compliance").ToString)<0.7,"Error","Passed") },False)).CopyToDataTable() (14.7 KB)


can u explain about this part?


It returns datarow consists of array items : a(0) , a(1) … in this case a is datarow from dtA and b is datarow from dtB.


Hi, thank you the sample is working, but in my real case i need write result in column “AR”, can u help this scenario

i’ve tried to add index on code, but its not work

PS : i have updated the question on thread, i remove condition number 3



How about the following using InvokeCode?
This updates specific column regardless of its column position.

dta.AsEnumerable.Zip(dtb.AsEnumerable,Function(a,b) Tuple.Create(a,b)).ToList().ForEach(Sub(t)
If t.Item1("KE1").ToString="Passed" AndAlso Convert.ToDecimal(t.Item2("Compliance").ToString)<0.7 Then
ElseIf  t.Item1("KE1").ToString="Passed" AndAlso     Convert.ToDecimal(t.Item2("Compliance").ToString)>=0.7
End If
End Sub
) (15.0 KB)


i have upload my code here, and still not worked on part of check percentage (prosespersen part)

pls help and give some advice, thank you (87.9 KB)