# How to obtain the count value of any column in uipath based on condition

I am trying to find count of a column values based on other column conditions, basically something similar to countif. e.g.
if I have a data table “Dt1”
C1 C2 C3
a y 3
a n 3
a y 3
a y 3
b y 2
b y 2
d n 0

So i want count of Column1 in Column3 based on the condition that column2 is “y”

How to do it, I have dt1 present in a datatable.

@amarjeet.kumar

Welcome to forums

Can you share your required output to us?

Thanks

A datatable with first two column would be the input, and the output would a datatable with additional column C3, having count of data in C1, based on condition in C2 so I/P would be
C1 C2
a y
a n
a y
a y
b y
b y
d n
and O/P will be

C1 C2 C3
a y 3
a n 3
a y 3
a y 3
b y 2
b y 2
d n 0

Hi,

You can get the condition count with below query

``````DtData.Select("'Assignment' <> '').Count
``````

I am new to UiPath can you please explain how to use this statement

Hi,

for example your condition is how many times ‘a’ appear in column 1

``````DtData.Select("ColumnA = 'a'").Count
``````

count function will give you the count of the values. similarly you can apply your condition and with count function get the count of the values on any column.

we can calculate by calculate by group by or by filtering check

orig data - dtData
prepare an empty datatable with buld datatatable having the 3 cols C1,C2,C3 - dtResult

Assign activity
Left: dtResult
Right:

(From d in dtData
Group d by k=d(“C1”).toString.Trim into grp=Group
Let c = grp.Where(Function (x) x(“C2”).toString.Trim.ToUpper.Equals(“Y”)).Count
From g in grp
Let ra = g.ItemArray.Append(c).toArray