Check two columns in datatable

Hello,

There is an easy way to accomplish this using Linq. I assume you want to check either if any of the rows in your datatable match the rule you described, or to get the rows that match the rule.

1. Check if any of the rows match the condition
Use this inside the ‘Condition’ block of the ‘If’ activity

dt.AsEnumerable.Any(function(x) x(0).ToString.Trim <> String.Empty andAlso x(1).ToString.Trim.ToUpper.Equals(“ORDER EXECUTED”) )

2. Return all the rows that match the condition
Use this in an ‘Assign’ activity, on the left side having a dataTable variable and on the right side the following condition:

dt.AsEnumerable.Where(function(x) x(0).ToString.Trim <> String.Empty andAlso x(1).ToString.Trim.ToUpper.Equals(“ORDER EXECUTED”) ).CopyToDataTable

In the conditions mentioned above, you have to replace the following:
dt - Replace this with the name of your dataTable through which you want to iterate

That’s it :slight_smile:

Let me know if you need any more help or info.

1 Like