Help with nested For Each Row in Data Table (C#). How to reference second DT

Hi,

I have two datatables, dtOut (dt1) and ProcessedDT (dt2). I am trying to check whether the values in the current row of ProcessedDT matches any of the values in all rows of dtOut.

I have a For Each Row in Data Table activity for dtOut and another For Each Row in Data Table activity inside for ProcessedDT with an IF activity.

How do i reference dtOut in my IF activity?

CurrentRow[“Amount”] == dtOut[“Amount”]
This is the general idea but am getting validation errors.

Would appreciate any advice thanks!

@justinkxc

For Each outerRow in dtOut (outerRow)
    For Each innerRow in ProcessedDT (innerRow)
       If: outerRow["Amount"].ToString().Trim() == innerRow["Amount"].ToString().Trim()
                 (Add your logic here for when the amounts match)


@justinkxc

  1. For your case in the for each row in datatable in the top you can change the item name to different names and use it
  2. Alternately you can get all the rows at once using linq dt1 = dt1.AsEnumerable.Except(dt2.AsEnumerable).CopyToDatatable…using this in assign will remove all the matching rows from dt1 and give the remaining rows

thank you both this has worked :slight_smile:

1 Like

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