I need to look for a value iterate through an datatable. For each of the row, I take the a value from the first and search for whether it is available in another.
This is the first table:
I am planning to take the value in the first column, a.input_extern_file_name, and count the number of times that it appears in the first column of the second table shown below:
And then I would add it to another datatable, MissingDT which will have all the columns in the first datatable and an extra column which has the Count of times the value in the first column appears in the second table. I am able to achieve this using the following LINQ:
(From d In SourceDT.AsEnumerable()
Let fileName = d.Field(Of String)("a.input_extern_file_name")
Let remarks = ReferenceDT.AsEnumerable().Where(Function(f) f.Field(Of String)("INPUT FILENAME") = fileName).Count()
Let ra = d.ItemArray.Take(3).Append(remarks).ToArray
Select MissingDT.Rows.Add(ra)).CopyToDataTable
However I am required to lookup the the value in the first column of the first file, a.input_extern_file_name, in 9 more datatables and update the number of rows in one Excel . So I thought I might use Invoke Code activity inside a For Each activity, where a different ReferenceDT is passed in as an argument.
However I don’t think it would work.
So I tried to write this query:
From d In SourceDT.AsEnumerable()
Let fileName = d.Field(Of String)("a.input_extern_file_name")
Let ra_sys = d.Field(Of String)("a.ra_sys")
Let colName = d.Field(Of String)("ColumnName")
Let remarks = ReferenceDT.AsEnumerable().Where(Function(f) f.Field(Of String)("INPUT FILENAME") = fileName).Count()
Select d
And Assign it to a System.Data.EnumerableRowCollection[System.Data.DataRow]
variable but it only returns one row.
Can someone assist me on this. How can I lookup a value in a column in one table in another Excel, but it isn’t just one Excel I need to search but I also need to look into 9 other excels.
Attached is also my Code. I attached 2 files, one has the traditional approach using UiPath activities(SearchForFile.xaml) another is my attempt to translate it into LINQ(Filter.xaml). I need to use LINQ as the dataset is quite big. Please let me know if you need more information. Thank you.
SearchForFile.xaml (24.0 KB)
Filter.xaml (14.1 KB)