Merge Data Table not working

This is what I intend to achieve:
Merge two datatables that have one column.
I read in each Excel with several columns and then merge it into one datatable and later print it out as a single column Excel.
This is code:

CN42N.xaml (19.3 KB)
This is the Excel I am getting:


I want something like this minus the header, in the first column:

Please help me.
Please let me know if you need more information.

Hi @RobinsonFrancis ,

1.Read 1st excel as DT1 and 2nd excel as DT2
2. Use filter data table activity



3.Use Filter Activity


4.Use Merge Data table activity

Thanks!

Hi,

Can you try the following expression instead of MergeDataTable?

dtResultOfMerge = dtResultOfMerge.AsEnumerable.Select(Function(r) r(0)).Concat(dtInputFilter.AsEnumerable.Select(Function(r) r(0))).Select(Function(o) dtResultOfMerge.Clone.LoadDataRow({o},False)).CopyToDataTable()

Regards,

With a minor change(I swapped the dtInputFilter with dtOutputFilter), I managed to get the output. However, I have a questions.
When I used the Merge Data Table activity, I got the column count of the dtOutputFilter after Merge Data Table activity and it’s result was 2. It is supposed to be 1. I don’t know why does Merge Data Table activity add the columns to be merged in the second column. Do you know why?

@RobinsonFrancis

Merge datatable will add column if the name or the datatype is different

To solve before merging reqrire column names to same name

Cheers

Hi,

dtResultOfMerge is read with AddHeaders option and probably has “Project def.” column,

However, dtInputFilter is read without AddHeaders option and its column name will be Column1 or Column2

So, MergeDataTable recognizes theses columns are not same because column name is different.
It may be also good if turn on add header option in all the ReadRange activities.

Regards,

1 Like

Thank you. It works.

1 Like

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