# Compare the value of some strings with 0

А B C
5 5 0
6 6 0
7 7 0
8 7 1
9 9 0

I need to set the “if” condition for column “C” value in row 1 <> 0 or value in row 2 <>0 or value in row 3 <>0 or value in row 4 <>1 or value in row 5 <>0. How do I do this without writing each line? There can be 100 rows instead of 5. The unit in line 4 is specified correctly and you need to compare the value in line 4 with 1.

@bolbat_evgenia
may we ask you to elaborate more on the requirements:

• row 1 <> 0 or value in row 2 <>0 or value in row 3 <>0 or value in row 4 <>1 or value in row 5 <>0
• The unit in line 4 is specified correctly and you need to compare the value in line 4 with 1.

in general we would work with a linq/select statement like

from d In YourDataTableVar.AsEnumerable
Where Not d(2).toString.Equals(“”)
… maybe other things to do

or ourDataTableVar.AsEnumerable.Any(Function (x) x(2).toString.Equals(“1”))

But as mentioned above the requirement / check rules are unclear and we do need more details on this.

Thanks

Thanks!
The values in column " C " are the result of calculations. In lines 1,2, 3,5, the result should always be 0, and in line 4, the result should always be 1. If the result of calculations in lines 1 or 2 or 3 or 5 is not 0, or in line 4 is not 1, a warning should be issued.
I hope that I was able to clarify my explanation.

so your explanation gives impression for the first 5, is the same pattern to apply for the next 5 rows:
Row 6,7,8,10 Col C = 0, Row 9 Col C != 1?

No, let’s assume that the values in rows 6,7,8,9,10 are 0

@bolbat_evgenia

lets assume

• the datatable from above
• an assign activity
left side check5RowsResult (Boolean)
right side:
``````{0,1,2,4}.All(Function (x) yourDatatableVar.Rows(x)("C").toString.trim.Equals("0")) And yourDatatableVar.Rows(3)("C").toString.trim.Equals("1")
``````

Or as an alternate:

``````(From d in YourDataTableVar.AsEnumerable.Take(5)
Select d("C").toString.Trim).ToArray.SequenceEqual({"0","0","0","1","0",})
``````

then it checks in one go row 1,2,3,5 Col C = 0 And Row 5 Col C = 1

Give a try in case of this is matching the case

@bolbat_evgenia
Попробуй такое
Let integer n = yourDT.Rows.Count
Let integer zerosRowCount = yourDT.AsEnumerable.Count(Function (row) row(“C”).ToString.Equals(“0”))

Let boolean cond1 = zerosRowCount.Equals(n-1)
Let boolean cond2 = yourDT.Rows(4)(“C”).ToString.Equals(“1”)

If not (cond1 And cond2) … [your logic]

Cheers)