How to write a variable in a new data table?

I am checking whether the variables in an excel DT1 named ReferenceNumber and WONumber exist in the other excel DT2, if so, I want to write these variables in a new excel one by one.

This is my DT1

This is my DT2

I want to write matching numbers in a third excel like this

I can compare two data tables but I don’t know how to write these variables.
Thank you.

1 Like


How about the following expression with Assign activity?

dtResult = dt2.AsEnumerable.Where(Function(r) dt1.AsEnumerable.Any(Function(r2) r2("Reference Number").ToString=r("Reference Number").ToString)).CopyToDataTable.DefaultView.ToTable(False,{"WO Number","Reference Number"})


Hi @makboga

Try with this expression

DT_Final = DT_2.AsEnumerable.Where(Function(r) DT_1.AsEnumerable.Any(Function(r2) r2("Reference Number").ToString=r("Reference Number").ToString)).CopyToDataTable.DefaultView.ToTable(False,{"Main WO","Reference Number"})

Check out this thread


It is writing all WO numbers I just want to write matching WONumbers which is belongs to ReferenceNumber


Can you share the sample excel file? @makboga

Hi @makboga ,

Could you try using Join Datatables Activity with Reference Number as the key column to match from both the Datatables. Keep the Join type as Inner Join. It should give you the required Output.

However, You would need to keep the Required Columns either by using Filter Datatable Activity or by using DefaultView.ToTable() method.

DT1.xlsx (12.5 KB)
DT2.xlsx (12.8 KB)

HI @makboga

Can you check out this XAML file

LinqJoinDt.xaml (6.0 KB)



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