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

HI,

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()

Sample20230515-4L.zip (14.7 KB)

Regards,

can u explain about this part?

Hi,

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.

Regards,

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

Regards,

Hi,

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
	t.item1("KE2")="Error"
ElseIf  t.Item1("KE1").ToString="Passed" AndAlso     Convert.ToDecimal(t.Item2("Compliance").ToString)>=0.7
    t.item1("KE2")="Passed"
End If
End Sub
)

Sample20230515-4Lv2.zip (15.0 KB)

Regards,

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

BlankProcess.zip (87.9 KB)