Linq Query for row count

I want to get the row count of an excel column “Column2” using linq query.I want to check if the row count is greater than 5. Is there any linq query for that. Also if there are no rows it throws an error but it should just move to the next activity

Hi @Amruta_George1

You dont need linq for it you can directly read the data into datatable(dt) and use dt.rowcount > 5

Are you looking for something on filtering and all?


No while using dt.rowscount if there are no rows then its throwing an error.

Hi @Amruta_George1

then initialize the datatable using ‘New Datatable()’ then it will not throw error


If there are values in dt then i also had to copy that values to new dt.

Hi @Amruta_George1

This is not copying the data. Thsi is to initialize the variable that you have for datatable

Say your datatable is dt then use assign or in ‘variable panel’ in default value give New Datatable() .This will initialize your dt so that it would not throw error and any new data if present will be added to dt itself



This is how you place it

Then when no rows are there it will give zero instead of throwing error

Hope this clears your issue


Hello @Amruta_George1

You can do as below. First assign activity is the declaration of the Datatable variable. So even if the datatable is null, it will not throw any error.

To get row count:



Hi @Amruta_George1 ,

What about this condition





dt.AsEnumerable.Where(Function(x) x(“Column2”).ToString<>Nothing).Copytodatatable.RowCount>0