How to get row count of specific column name

Hi,

I want to get row count of a particular column only within a data table,
(total count of rows having values only, ignoring empty rows)

Thanks in advance
Mohini Nemade

Have you tried using Linq?

You can get the count with something similar to:

(From row As DataRow in mydatatable.Rows
Where Not String.IsNullOrWhiteSpace(row("mycolumnname").ToString)
Select row).Count
1 Like

Hi @mohininemade301094,

Good, so kindly use this method,
you will be having a name for datatable , say “dt_1”

  1. Inside for each row loop, mention the datatable name, with for each row loop variable name “rows”
  2. say you want to know the total row count (ignoring empty rows) of second column, with index 1, use a if condition mentioning, Not String.IsNullOrEmpty(rows(1)). or you can mention even column name instead of index like Not String.IsNullOrEmpty(rows(“ColumnName”))
  3. Use a counter with assign activity, that adds 1 to the counter if the above condition get satisfied.
  4. Thus that counter gives you the total row count ignoring the empty rows…

Cheers…

You will be getting row count.

3 Likes

Hello @mohininemade301094,

You use this linq in the assignment activity to an interger variable.

DtTable.Rows.Cast(Of DataRow)().Where(Function(row) Not row.Item("ColName") IsNot DBNull.Value Or row.Item("ColName").ToString() <> "").Count 

Regards
Balamurugan.S

12 Likes

Thanks! It worked well

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.