Suggest a expression to get it
Hi
Welcome to UiPath community
Hope this would help you
TestDt.AsEnumerable().Select(Function(x) x.Field(Of String)(“YourColumnName”).Trim).ToArray().Where(Function(y) Not String.IsNullOrEmpty(y)).ToArray().Count
Cheers @Viswanathan_M
Hi @Viswanathan_M, welcome to the Community.
You can convert the specified row into an array and take the count of the elements, which gives the number of rows present in the column.
dt.AsEnumerable().Select(Function(row) row("Column1")).ToArray().Count()
Hope this helps,
Best Regards.
Hi @Viswanathan_M ,
Ideally all the columns in a Datatable will have the same row count, So we directly use the below :
DT.Rows.Count
But if the intention is to get only the Non-Empty rows Count in a column, then we can use the below Expression :
DT.AsEnumerable.Where(Function(x)Not(String.IsNullOrWhiteSpace(x("YourColumnName").ToString))).Count
The above is also when you only have empty values in the end of the column.
Got the Solution its working fine Thanks Palaniyappan.
I am interested in Learning this expression, from where did i learn this expression.
Thanks for providing solutions on forum.
This expression is not working for empty rows in data table, mean count 0 it’s not working.
Regards,
First check whether the datatable has records in it before using the linq query with a simple IF condition
have to check only if that particular column has records. because other columns having records and hence data table will obviously say that has records.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.