Mr.H
July 31, 2021, 5:23am
1
Hi Everyone.
I have 2 datatable same structure as attached file… I want to matching “Scope” Col between 2 datatable without loop rows if the “Name” Col is same value
Are LinQ or Join Datatable are possible do this ? And how to do this ?
Thanks in advance!
Input Table:
Out Table
Expected result
Book1.xlsx (10.3 KB)
Hi @Mr.H
Apart from using join I think this query can help in
dt1.AsEnumerable().ToList().ForEach(Sub(row) row(“Scope”)= If(dt2.AsEnumerable().Where(Function(r) r(“Name”).ToString.Equals(row(“Name”).ToString)).Count<>0,dt2.AsEnumerable().Where(Function(r) r(“Name”).ToString.Equals(row(“Name”).ToString))(0)(“Scope”).ToString, Nothing))
Use this code in invoke code with dt1 as in/out argument and dt2 as in argument here
I am assuming that dt1 is Input Table
dt2 is Output Table
Hope it helps
Mark it as solution if it solves ur query
Regards
Nived N
Happy Automation
2 Likes
Actually I feel join isnnot needed here as ur need to update the value of scope column in input table from output table by look-up
Mr.H
July 31, 2021, 8:34am
4
Hi Bro.
If i want to add more condition to check same value at the “Position” Column as below picture, how to customize more in your code?
And i think it still must loop rows in your code… if two datatables have some thousand rows, it will take time to match same row between 2 datatables.
Is there any other way to match them without loop Bro ?
Hi @Mr.H
Well my code do the process of lookup and updating data too…
And then u can write dt1 directly into the excel itslef
Also can u explain more about how u need to consider position column too?
1 Like
Mr.H
July 31, 2021, 9:16am
6
NIVED_NAMBIAR:
dt1.AsEnumerable().ToList().ForEach(Sub(row) row(“Scope”)= If(dt2.AsEnumerable().Where(Function(r) r(“Name”).ToString.Equals(row(“Name”).ToString)).Count<>0,dt2.AsEnumerable().Where(Function(r) r(“Name”).ToString.Equals(row(“Name”).ToString))(0)(“Scope”).ToString, Nothing))
Thanks you Bro for your solution… i known how to customize to apply into my sample.
I will find more another way to compare the performance while matching 2 datatables can up to some thousand rows.
1 Like
Hi @Mr.H
Is this method is taking more time than required?
1 Like
system
(system)
Closed
August 3, 2021, 9:50am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.