For each row in Table and If condition (build data table OK / Add data row OK)

Hello could you help me how I can include the condition for check if there is code different of “BD” or “00” for all rows in the table and other condition for check if the table has only one specific code for all rows.
Example 1: Table: DT_SAMPLE
codes: FA, AC, BD
Check if there is the code different of “BD” or “00” for ALL lines.

Example 2: Table: DT_SAMPLE2
codes: BD, BD, BD.
Check if there is only the codes “BD” for rows.

Hi @Felipe_Sternberg ,

This is assuming that you are using a For Each Row in DataTable to validate the results

To check if either of the row items contain a given code, you can try this →

CurrentRow.ItemArray.Any(Function(a) a.ToString.Contains("BD") OrElse a.ToString.Contains("00"))

To check if all items in a given row contains a given code, then give this a try →

CurrentRow.ItemArray.All(Function(a) a.ToString.Contains("BD") OrElse a.ToString.Contains("00"))

Both return Boolean values, which means they can be directly put into an If Activity.

Now if you want to check if any of the row items contains a given code, then this is what you should use :

dt.AsEnumerable().Any(Function(a) a.ToString.Contains("BD") OrElse a.ToString.Contains("00"))

To check if the entire dataset contains just this code :

dt.AsEnumerable().All(Function(a) a.ToString.Contains("BD") OrElse a.ToString.Contains("00"))

Kind Regards,
Ashwin A.K

Hello, I´d like to know if for all rows in Data Table activity DON´T have one specific code (“BD”).
For example , I have 03 lines in Data Table (BD, 00, BD) and I need to do something ONLY if all rows are “BD”. Which condition I can to use?


you can use a single filter data table activity, and count the result


My variable is dt_sample (DataTable type) and I put the condition as:
For each row in dt_sample
dt_sample.AsEnumerable().All(Function(a) a.ToString.Contains(“BD”))

the Table has BD, BD, BD codes but is not appearing the the message that I included.

Hello, I don´t know the quantity of rows and only I´d like to know if exist only the “BD” Code for all rows.
Could you please put one example for me? thanks


The following expression will return True if there is no “BD” in the datatable.

dt_sample.AsEnumerable().All(Function(r) r.ItemArray.All(Function(c) not c.ToString.Contains("BD")))



check this example, you may got the idea

test.xaml (11.9 KB)


I put this in the condition and and into the then one message box for show me “OK”
but is not working.
Before I confirmed that I have the BD, BD and 00.
One suggestion?


Can you share your data as file? it’s no problem if dummy data.


2-ReadTxtFileAndExtractCharFromPosition.xaml (20.3 KB)
See please the end of the job that has the condition.

the example is appearing this problem…


I suppose the condition of checking “BD” would be as the following, because it seems to check if “BD” exists in not whole the datatable but the row.

row.ItemArray.All(Function(c) not c.ToString.Contains("BD"))

And if dtResult.RowCount doesn’t work, can you try dtResult.Rows.Count ?


Both dtResult.RowCount and dtResult.Rows.Count no working. this example will help me.

the condition row.ItemArray.All(Function(c) not c.ToString.Contains(“BD”))
appear the message box for the others two rows that the code is “BD”.
I need that if appear the message only if all line are BD.


Can you try the following? This returns true if all the row items contain “BD”.

row.ItemArray.All(Function(c) c.ToString.Contains("BD"))


The condition is correct but if I put the message box, is appearing yet with the quantity of rows that I have with “BD”.
I have 03 lines (00, BD, BD) is appearing 02 times the message box but I need know when is not exist all rows with “BD”. How can I do please?


I suppose it’s better to check if “BD” exists in the datatable in advance, as the following. Does this work for you?


I got to fix the example and will test it. thanks.