Excel scenario

Hello UiPath enthusiasts,

I’m currently working on a project where I need to perform a lookup operation between two DataTables. Let’s say I have DataTable A with columns “ID” and “Name” and DataTable B with columns “ID” and “Details.” How can I efficiently perform a lookup to retrieve the “Details” from DataTable B based on the “ID” in DataTable A? Can someone guide me through the steps in UiPath Studio?

Hi @vinod_lagudu ,

In UiPath Studio, you can efficiently perform a lookup between two DataTables using LINQ and the following steps:

  1. Use LINQ to Perform the Lookup: Employ LINQ queries to perform the lookup between DataTable A and DataTable B based on the common “ID” column. Here’s an example LINQ query:

csharpCopy code

DataTable resultTable = (from rowA in dataTableA.AsEnumerable()
                         join rowB in dataTableB.AsEnumerable()
                         on rowA.Field<int>("ID") equals rowB.Field<int>("ID")
                         select new
                         {
                             ID = rowA.Field<int>("ID"),
                             Name = rowA.Field<string>("Name"),
                             Details = rowB.Field<string>("Details")
                         }).CopyToDataTable();

or U can simply use the Lookupdatatable activity and achieve the same .

Cheers !

Using linq query or activity is suggested ??

Linq query is faster and u can achieve the same through effective use of activity lookupdatatable

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.