hello Community
I want To Compare Two dataTables And Acheck if The Data of dt1 Column1 Exist In Dt2 Column If true then i have to Check Condition Like Dt1 qty is less than dt2 Qty
Dt1
Dt2
Thanks
hello Community
I want To Compare Two dataTables And Acheck if The Data of dt1 Column1 Exist In Dt2 Column If true then i have to Check Condition Like Dt1 qty is less than dt2 Qty
Dt1
Dt2
Thanks
Use a assign activity like this
Dt_Output = (From d1 In dt1.AsEnumerable Join d2 In dt2.AsEnumerable On d1(0) Equals d2(0) Where d1(1) < d2(1) Select d1).CopyToDataTable()
Hope this helps
Cheers @Prateek_Gulab_Pathak
thanks for the reply ,but i have to check first if all values from dt1 Column 1 Is exist in dt2 column 2 then iwill apply less than condition
Yeah it does the same This query will first join the two DataTables on the Column1 column. Then, it will filter the results to only include rows where the dt1 qty is less than the dt2 qty. Finally, it will copy the results to a new DataTable.
If u want to do them separately then use a IF activity first with condition like this
(From d1 In dt1.AsEnumerable Join d2 In dt2.AsEnumerable On d1(0) Equals d2(0) Select d1).Any()
If true it goes to then block where use the above same assign activity from previous comment
Cheers @Prateek_Gulab_Pathak
dt1Values = Dt1.AsEnumerable().Select(Function(row) row.Field(Of String)("Column1"))
dt2Values = Dt2.AsEnumerable().Select(Function(row) row.Field(Of String)("Column1"))
' Use LINQ to check if all values in dt1Values exist in dt2Values
allValuesExistInDt2 = dt1Values.All(Function(value) dt2Values.Contains(value))
If allValuesExistInDt2 Then
' All values in Dt1 Column1 exist in Dt2 Column1
' You can perform the desired actions here
Else
' Not all values in Dt1 Column1 exist in Dt2 Column1
' Handle this case as needed
End If
Hope this helps!!
Thanks for the reply again , just one more question here d1 and d2 are Column Names ???
@Palaniyappan
Please try this
Dt1.AsEnumerable.Where(function(x) dt2.AsEnumerable.Any(function(y) y(0).ToString.Equals(x(0).ToString) AndAlso Cdbl(x(1).ToString) < cdbl(y(1).ToString))).CopyToDataTable
Here 0 and 1 are the column positions you can use the column names inplace of numbers as well
Cheers
hello @lrtetala ,thanks For the reply
Can You also tell what Datatype If to give this dt1Values & dt2Values
IEnumerable(Of String
You can try this
Array1=dt1.AsEnumerable.select(function(x) x(0).tostring).toarray
Array2=
dt2.AsEnumerable.select(function(x) x(0).tostring).toarray
Booloutput= Array1.Except(Array2).Count() = 0
If booloutput gives true or false
Use this Linq Query
(From row1 In dt1.AsEnumerable()
Join row2 In dt2.AsEnumerable()
On row1.Field(“Item”) Equals row2.Field(“Item”)
Where row1.Field(“Qty”) < row2.Field(“Qty”)
Select row1).CopyToDataTable
Cheers…!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.