Hi there. I am stuck at a task where I need to manipulate data table functions. However, I don’t know how the it could be done.
Currently, I have 2 data tables - which I call DT1 and DT2. Values in them are all strings.
DT1 is a list of numbers. DT2 consists of 3 columns, i.e. Number, Date, and Transaction Amount.
What I want to do is that for each row in DT1, find if there is the same number in DT2, and if there is, return the corresponding date and transaction amount to DT1, or create DT3 to store it. If the number could not be found in DT2, return “Not Found” in both columns (Date & Transaction Amount).
Build a datatable DT3 which stores the output results using build datatable activitiy.
Use for each row to loop through each row of DT1
Inside the for each row, do the following .
Using the lookup datatable activitiy to lookup up.the number in DT1 in DT2 and extract the corresponding data, for lookup datatable activitiy configure following properties.
Lookup datatable : DT2
lookup value: row(“Number”).ToString
Lookup Column Name : Number
rowindex : index, where index is int32 varaible which stores the row index of lookup value in DT2
then use if Condition with condition as
index <>-1
Then
Use add datarow activity with adding
{row(“Number”).ToString,DT2.Rows(index)(1).ToString, DT2.Rows(index)(2).ToString} to DT3
Else:
{row(“Number”).ToString,“Not Found”,“Not Found”} To DT3
Outside the loop use write range activity to write the DT3
Hello Nived, I am lost at the add datarow activity. Could you advise where to input {row(“Number”).ToString,DT2.Rows(index)(1).ToString, DT2.Rows(index)(2).ToString} to DT3? The Add Data Row activity only has 3 Input properties, i.e. ArrayRow, DataRow, and DataTable.
For the record, I tried the Join Data Table activity but it seemed like it doesn’t output the result I wanted. Empty value is acceptable if the number is not found, but the output data row has to be in the same order as the DT1. Moreover, there seems duplicated columns occurred.