Hello Community,
I want to get the filtered data based on primary and secondary key from two different tables.
First table key column match with second table key column, then get the merged input of two tables as one row
Input Table Data-1:
Input Table Data-2:
Expected Result:
Thanks,
lrtetala
(Lakshman Reddy)
September 4, 2024, 5:39pm
2
Hi @kishore_reddy2
Use below query
(From row1 In DT1.AsEnumerable()
Join row2 In DT2.AsEnumerable()
On row1("Key").ToString Equals row2("Key").ToString
Select MergedDT.Rows.Add(row1("Key"), row1("First Name"), row1("Last Name"), row2("Phone Number"), row2("Location"))
).CopyToDataTable()
Regards,
Hi @kishore_reddy2
You can use the core activity for this case: UiPath.Core.Activities.JoinDatatables
Join Type : Inner
Please refer the below xaml for the solution.
JoinDataTables.xaml (14.2 KB)
Hi @kishore_reddy2
LINQ Query is the best optimized possible way to achieve your requirement.
I have provided the working code.
(From rowX In DT1.AsEnumerable()
Join rowY In DT2.AsEnumerable()
On rowX.Field(Of String)("Key") Equals rowY.Field(Of String)("Key")
Select FilteredDT.Rows.Add(rowX.Item("Key"), rowX.Item("First Name"), rowX.item("Last Name"), rowY.Item("Phone Number"), rowY.Item("Location")).CopyToDataTable
Happy coding
Cheers,
Anil_G
(Anil Gorthi)
September 4, 2024, 6:55pm
5
@lrtetala
Join datatable would do the job
If you want to remove any extra columsn then use filter datatable and you can remove them
Cheers
Thanks for the solution @batthula.p949 It is working for me .
system
(system)
Closed
September 8, 2024, 5:13am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.