Help with datarow filtering

Hi, I have a datatable as below. After looping it in for each row activity. I want to do different sequence for rows which is has column B as 43712653 and different sequence for rows which is has column B as 43745260.

I have tried using if row(1).tostring = “43712653” or row(1).tostring.contains(“43712653”). However, instead of writing rows which has a column B = “43712653”, it is writing the whole datatable inside the If.

image

Pls help.

Thank you xoxo

Hi @sangasangasanga

To correctly reference row Item, use this inside your For Each Row activity:

row.Item("columnName").ToString

In your case, the if condition should look like this:

row.Item("columnName").ToString.Contains("43712653")
2 Likes

Hi @loginerror Is there any other way to do it as it doesn’t have a column name

Actually, any Data Table will have a column name :slight_smile: It is probably a default one. You can find it out by using Output Data Table activity and printing it to the console.

But you can also use a 0-based index for your column:

row.Item(1).ToString.Contains("43712653")
1 Like

@loginerror
It works for
row.Item(“columnName”).ToString.Contains(“43712653”)
but it doesn’t work for
row.Item(“columnName”).ToString.Contains(“43745260”)
it outputs the rows for both 43712653 & 43745260

You can use select statement. Please check the below link.

How to use select statement

Hi, I tried, still not working
it outputs the rows for both 43712653 & 43745260 even though 43745260 is selected.

Pls help. Thank you.

You need to assign a Array(DataRow) for select statement.

image