Get count of word in column of Datable

Hi,
In the below datatable i need two things .Any help?
*The count of success in column state
*Retrieve Id where the state is success
*I need 5th column values which doesn’t have column name

id name state
25 john success
65 regan failure

@ranjani,

  1. Iterate that DataTable using For Each Row activity

In assign, int flag = 0
int count = 0

If row(“state”).toString.equals(“success”)
then flag = 1
count = count + 1
End If

If flag = 1
then requiredID = row(“id”).toString
End If

End loop

Display count value.

1 Like

Please find the Below Solution for ur both Questions

Use Assign Activity
1.
Output Will be Integer

CountA = from x in DatatableVariable.AsEnumerable() where convert.tostring(x(“state”)).trim.tolower.contains(“success”)
select convert.tostring(x(“id”)).tolist.count

output will be list Collection of string

listA = from x in DatatableVariable.AsEnumerable() where convert.tostring(x(“state”)).trim.tolower.contains(“success”)
select convert.tostring(x(“id”)).tolist

1 Like