If condition better approach

Hi @samantha_shah

Your data is in the datatable, success and failure is in the column and you want to get the Count of Status rows and Failure rows.

If this is your case, then you can use the LINQ expressions to get the Count and store in a Variables.

- Assign -> Success_Count = dt.AsEnumerable().Count(Function(X) X("Column name").Equals("Success"))

- Assign -> Failure_Count = dt.AsEnumerable().Count(Function(X) X("Column name").Equals("Failure"))

Note : Success_Count and Failure_Count are the Int32 datatype variables and change the column name in the both LINQ Expressions.

Hope it helps!!

1 Like