How to filter the data if one column values less than other column value(a<b)?

Hi Team,
Please help me on this .

a b c
2 5 7
6 5 4
5 6 7
4 2 1
  1. Read range of your excel and store output as datatable
  2. Use a for each row activity
  3. Use an if acitivity with the following condition: row.item(“a”).tostring<row.item(“b”).tostring

The robot will check for every row if value a is < value b.

@yannip’s solution is a good idea, but just wanted to make a correction that you will need to convert each string to a number before you can compare them with < or >
ie CInt(row("a").ToString.Trim) < CInt(row("b").ToString.Trim)

Here is a snippet, which also shows how to check if the value is a number before it tries to convert it, so no errors arise in the future:

Alternatively, you can also take a more efficient approach to avoid cluttered code and provide quicker processing time by filtering the datatable to an array of rows using query:

dt1.AsEnumerable.Where(Function(r) If(IsNumeric(r("a").ToString.Trim) And IsNumeric(r("b").ToString.Trim), CInt(r("a").ToString.Trim) < CInt(r("b").ToString.Trim), False ) ).ToArray



Indeed he needs to make it int, i forgot to add that.
I’m sure your alternative will work as well, but I would not have come up with that as i’m still a rookie :-)!

1 Like

thank you very much…

1 Like

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