Add header in DT

Hi Guys, @ppr
I have multiple data tables with headers. like dt1 and dt2 and so on. I want to add dt1 and dt2 to finalDT and some headers to same finalDT.Like
dt1
name, id, amount
abc1,23,23444
abc2,25,5435

dt2
product, quantity, value
abc1,23,23444
abc2,25,5435
abc3,26,5434
bc4,27,5436

finalDT
name, id, amount,new col1, product, quantity, value, new col4, new col2, new col3
abc1,23,23444, ,abc1,23,23444
abc2,25,5435, ,abc2,25,5435
, abc3,26,5434
, bc4,27,5436

in final dt i want to add new headers as well. Please some one assist me.
Thank you

Hi,

Can you try the following sample?

Sample20210412-1.zip (2.9 KB)

Regards,

1 Like

Hi @Yoichi , Thank you for quick response.
for my side, is it possible to use assign activity instead of add column. After added the join data table if i want to add inside header like between id and amount. Please explain if possible.

I have tried used this but not working
customerDT.Columns(6).ColumnName= “newcol1”

Thank you

Hi,

We can also write it as the following, using Add method.

img20210412-3

After added the join data table if i want to add inside header like between id and amount.

I think It’s difficult to insert column except at the end.
We need to use SetOrdinal method or Filter DataTable activity etc for reordering columns.

Regards,

Hi @Jesmine,

you can use “ColumnName” when you want only to rename the name of an existing column and not for adding another column, for example in your case:

finalDT.Columns(2).ColumnName = “amountRenamed”

Gio

I got the output like image using your flow
image
It should to push data from 1st row but it did after done from 1dt

my workflow:

Thanks

Hi,

Can you share you workflow and data (original data and expected result) , if possible?

Regards,

@Jesmine
most of the building blocks were mentioned. The flow could look like this:

  • join datatable - dt1 to dt2 - Full Join

  • for each activity on {“new col1”,“new col4”, “new col2”, “new col3”}

    • add data column
  • define a string array with the final structure and its column order:
    arrColls = {"name", "id", "amount","new col1", "product", "quantity", "value", "new col4", "new col2", "new col3"}

  • extract from join result datatable:
    yourJoinResultDT.DefaultView.toTable(False,arrColls)

if i use full join then its output looks like
image

2nd dt started from bottom where 1st dt end.

Thank you

@Jesmine
screenshots looks different to the mentioned column structures. May we ask you on following:

  • please share with us the settings from your configuration of the join datatable activity

Also have a look here as an iontroduction to the join data working concept:

i have sent the workflow and file. could you check please?

@Jesmine

refering to the provided sample data from above we saw clearly following:

  • dt1:name can be used for pairing dt2 rows together, joined on dt2: product
  • abc3, bc4 are not present in dt1
  • the described output is similar to a result of a full data join (we provided link which demo cased the concept)

the used data from the excel are not following the requirements and differs fundamentally:

  • there is no datacolumn in dt2 that can be used for joining
  • based on excel there cannot be derived a rule which defines on how dt1 rows are paired with dt2

In such a case we recommend to go back to the requirements and redefine the missing parts.

In case of just bringing dt2 data aside to dt1 within the excel give a try on 2 write ranges and use for second write range an offset (range setting)

I have shared the workflow and file to inbox. Could you check please?