Add data to an existing datatable without mentions rows

I have Excel file which has different type of data… and I have used filter to sort the data…
after filter one type of data, I add data to a datatable.

I have simply used
Assign activity: → varBuildDT = new Datatable

varExcelData has filtered data

Then i have used assign again which add data → varBuildDT = varExcelData
thats how i add the first filtered data to a datatable called varBuildDT

Now I have another filter which sort an other type of data from same file. But when i use same logic of assign it also add Header of table… (which I do not want)—

So I tried another way to solve this… on first filtered data I have used Assign to add data but on 2nd filtered data I have used add data row
image

it is working but issue is, I have to specify Rows number which I dont know … means after filter the data I dont know If I have any data or not

So how can i use this add data row to add data without mentioning rows…

can someone help…

Hi,

Can you share specific input and expected output as file?

Regards,

Hi @Ellen , not too sure if I understood everything correctly.

I recommend loading the full Excel data into a datatable, rather than filtering in Excel and loading into datatable.

  1. Load the full Excel data into a datatable, let’s call it dtInput
  2. Clone dtInput and create dtResult. dtResult = dtInput.Clone
  3. Now filter dtInput using the first filter criteria, save the filtered DT as dtFilter
  4. Check if dtFilter has rows. dtFiletr IsNot Nothing AndAlso dtFilter.RowCount > 0
  5. Merge source dtFilter to destination dtResult
  6. Repeat this process for other filter conditions - may be you can put steps 3 - 5 in a loop
1 Like

I believe what you are looking for is a “Merge datatable” activity.
With this you can copy data from varExcelData(filtered data table) to varBuildDT (Destination table).
Irrespective of how many rows the filtered datatable(varExcelData) has, you can Merge with your main datatable(varBuildDT), just put a condition to check if the filtered Datatable has Rows and then Merge, else Skip.

regards
SG.

thanks to @sudster … it worked but it still gave me an error when i have only one row after filter.

Thanks to @golla.sandeep … merge worked for me and it solved my problem. Thanks for the help.

1 Like

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