You’re getting source contains no data rows because there are no rows with the value of 1000. So CopyToDataTable throws this error. It would be simpler to just use a Filter DataTable activity to filter into a temp dt, then check the rows count.
The error you’re encountering (“The source contains no datarows”) is occurring because the DT.Select("[Business Area] = '1000'").CopyToDataTable() expression tries to copy the filtered rows into a new DataTable, and if there are no matching rows, it raises an error.
To count the number of items in the “Business Area” column that have a value of 1000, you can use LINQ to directly count the matching rows without attempting to create a new DataTable. Here’s how you can do it:
DT.AsEnumerable() converts your DataTable DT into an enumerable collection of DataRow objects.
.Count(Function(row) row.Field(Of String)("Business Area") = "1000") counts the rows where the “Business Area” column has a value of “1000.”
= 1000 checks if the count is equal to 1000.
This condition will be true if there are exactly 1000 rows with “Business Area” equal to 1000 in your DataTable. If the count is not 1000 or if any “Business Area” value is different from 1000, the condition will be false
This is basically because of trying to find the rows which are EQUAL to 1000
And sometime if there is no record it will throw as no Datarow found and we won’t get the count as zero
For that first use a IF condition to validate whether it has any rows with value as 1000 with this expression in IF activity with condition like this
Hi @ppr , how will this statement change if, we need to check for two columns instead of just one here being Business Area. Say another Column is “ID”.