Using other DataTable to loop through other DT

hi all

I need some help with a specific step.

I want to extract one column from the MainDT then create one NewDT using only this column.

And then I want to use NewDT to loop through the MainDT and Calculate the sum of another column of another Column in MainDT depending on the looping of MainDT with respect to the NewDT.

Anyone?? Please help.

@ALL

Looking at your explanation, you are only using the NewDT to iterate through MainDT. If that is the case, just use a for each row activity on the MainDT to calculate the values without the need for the extracted datatable.

https://activities.uipath.com/docs/for-each-row

@AndyD
i know. but what i wanna do is i wanna compare the values from the and iterate through the MainDT because this this data may change in the future. So thats why i wanna compare. Dont wanna hardcode it. i wanna keep it in a way, such that it depends on the current data in the MainDT.

Consolidated_Finance_Report_Example.xlsx (78.8 KB)

Please check the excel file.

Suppose i wanna iterate through “Account Name” Column and wanna sum up the values in “Invoice Excl Vat Amt” that come under same account name. And these ‘Account Names’ may or may not change in the future.

@AndyD

Hi @AryanSingh

I have done it using Database connection.
loopDataTable.xaml (10.5 KB)
Please confirm is this what you were looking for.

BR
Devbrath

1 Like

thanx @Devbrath_Rajkhua

Will check and tell u.

Ah ok, that makes more sense now then. I would:

  1. Read range of column E (Account Name) into a table (AccNameDT)
  2. Use Remove Duplicate Rows activity to leave only a list of unique names
  3. Add a data column to the AccNameDT to store the invoice totals calculated later
  4. Read range for entire sheet into another table (ReportDT)
  5. Use a for each row activity on AccNameDT
  6. In the loop, filter the ReportDT by the current row account name - Row(0).tostring
  7. Still in the loop, sum up all values in the “Invoice Excl Vat Amount” column for the filtered DataTable and store it in Row(1)

There is no hard coding of values here, it will update the acc names each time you run the process from the input sheet

1 Like

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