Count the "Yes" from excel column

Hello,
I have 1 excel file having a column name as ‘Found’ and it has “Yes” and “No” value in it, I need to count the number of “Yes” present in that column.

Thanks
yes count

Hey @Gagan_Chaudhari,

You can use filter datatable activity to filter by “Yes” and than you can use count method to count the number of rows.
dt.Rows.Count() this will return you the number of rows available in the datatable.

Thanks,
Sanjit Pal

hey

try this

yourDT.AsEnumerable.Where(function (x) x("Found").ToString.Trim.Equals("Yes")).CopyToDataTable.RowCount.ToString

Regards!

1 Like

@Gagan_Chaudhari Use below workflow

Example.zip (9.5 KB)

Input

Capture

Output

Capture1

Hey @Gagan_Chaudhari,

you can try following Linq

dt.AsEnumerable.Count(Function(x) x("Found").ToString.ToLower.Trim.Equals("yes"))

Above Linq will Count the rows where Found column has the value as Yes in any case

ToLower - this is used just to handle edge cases, if in case the column contains different versions of YeS*

Thanks,
Saurabh

1 Like

Hi @Gagan_Chaudhari we can achieve this using LINQ approach

Let’s say you have read that excel and stored in datatable DT

Now use an assign activity and let variable type be an integer
image

kindly use below linq query

(From r In DT Where (r("Found").toString.ToLower).equals ("yes") Select r).Count

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