How to add row value in the specific column

Hello fellows,

I have a DT which contains the following columns:
DT1

Client, Subclient, Type, Flag
ABC DC Daily
PWR DB Daily
RDS EE Monthly

Another table has the following values:
DT2

Client, Subclient, Type
ABC DC Daily
PWR DB Daily
RDS EE Monthly
ABJ DC Daily
PNR DB Daily
RLS EE Monthly

To compare with DT2 I’m using filter data table activity to get match row from DT1 because The table has 100+ rows.

Now, After matching the data row I want to add row values in the Flag column in the front of the matching row as “check”

Thank you

Hi!

Read both dt as f.ex. dt_1 and dt_2. Next place for each row in dt_1. Inside place filter data table and as datatable in place dt2 and output as new variable dt_check. In filter option place 0,1,2 in column and value row(0).toString, row(1).toString,row(2).toString (assuming that all columns are string type)

image

After that place if:

image

This solution should check and write result in Flag column 1 by 1 :slight_smile:

@Yameso

DT1 has report data.
Client, Subclient, Type, Flag
ABC DC Daily
PWR DB Daily
RDS EE Monthly

DT2 has multiples rows
Client, Subclient, Type
ABC DC Daily
PWR DB Daily
RDS EE Monthly
ABJ DC Daily
PNR DB Daily
RLS EE Monthly

DT2 is in for each row loop
DT2 will check for each row with filtered data table row

if DT2 row == filtered data table row

Then
write “check” in the DT1 table in front of the matching row

Please confirm:

In both dt you have the same column. In dt_1 you have flag column to fill with some values?

if so then change order - you want to work and have result in dt 1 so in for each row u can get and write data and also use other datatables if they were created before for each row.

@Yameso
In both dt you have the same column. In dt_1 you have flag column to fill with some values?
Ans: Yes right

DT2 has 250+ row data
DT1 has 100+ row data

I want to check If the Dt1 row present in Dt2 or not.
If yes then write “check” in the Flag column of Dt1
If not then no problem

This process will work untill all the rows of Dt1 table checked with Dt2 table

So in that case you should try my solution as I wrote above :wink:

In for each row DT1 u take values from that dt, search it in dt_2 with filter data table and gives result to technical dt_check. If dt_check has values it means dt_2 had those row inside so if statement will write “check” to column 4 (row(3)) with value “check”. if not it can leave it empty:

1 Like

@Vrushali_Gave
for this case we can use the join datatable activity
(join type: left join, dt1 to dt2)

from the join datatable result we can calculate the flag matched/ not matched

as an alternate a LINQ statement can be written.

Also have a look here:

1 Like

@ppr But how can I write in that data table for matched row?

Hi @Vrushali_Gave
You can try this way too using invoke code with DT3 as out argument and DT1 and DT2 as in argument

DT3 = DT1.AsEnumerable().Intersect(DT2.AsEnumerable(),System.Data.DataRowComparer.Default).ToList().ForEach(Sub(row) row(“Flag”)=“check”)

then write the DT3 using write range

You can try this

Regards

Nived N

Happy Automation

based on the evaluation / postprocessing of the join result you can create the target datatable having the matched/not matched information.

Here e.g. a LINQ can help. The matched / not matched information can be retrived by checking the join column from right side table if it is null or not

@NIVED_NAMBIAR Getting an error:

image

Do like this

use assign activity first
DT3 = DT1.AsEnumerable().Intersect(DT2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable

Then after this use code in invoke code with DT3 as In/Out argument

DT3.AsEnumerable().ToList().ForEach(Sub(row) row(“Flag”)=“check”)

It will work

Regards

Nived N

Happy Automation

@NIVED_NAMBIAR
Getting an error
image

image

did u check whwther the rows u need are there or not @Vrushali_Gave

@NIVED_NAMBIAR Yes, I have checked

Hi @Vrushali_Gave
Ca u share the sample excel files?

@NIVED_NAMBIAR Yes, Sure

Kindly check the attached excel file:
Book2.xlsx (14.7 KB)

DT2 table will check for each row in the DT1 table
If DT2 found a row in the DT1 table then, the bot wants to write “check” in the Flag column of DT1 table in fron of the matching row

how did u read this file

did u put the starting range in read range as B1?

@NIVED_NAMBIAR No, I read from B3 range

Hi @Vrushali_Gave

Can u try to read from B1?