Check count of values present in two coulmns

Dear Team,

Currently i am using below syntax to get the count of “Yes” from"Emails Recieved" column,

AddRow(“Emails Received”) = VRLDTMar.AsEnumerable().Count(Function(row) row.Field(Of String)(“Email Received”).Contains(“Yes”))

Now my requirement is i have to check one more column “Latest Report”.
if both column has “Yes” then only count.

i,e., Get the count where both column has “Yes”.

FYI,

Email Received Latest Report
No
Yes Yes
Yes Yes
Yes No
Yes Yes
Yes No
Yes Yes
Yes Yes
Yes No
Yes Yes
Yes Yes

Thanks,
Amol

1 Like

Hi @Amol_Golhar

Try this:

countYes = VRLDTMar.AsEnumerable().Count(Function(row) row.Field(Of String)("Email Received").Equals("Yes") AndAlso row.Field(Of String)("Latest Report").Equals("Yes"))

Hope it helps!!

1 Like

Hi @Amol_Golhar

Try this

DT.AsEnumerable().Count(Function(row) row.Field(Of String)("Email Received").Equals("Yes") AndAlso row.Field(Of String)("Latest Report").Equals("Yes"))

Cheers!!

1 Like

Hi @Amol_Golhar

AddRow(“Emails Received & Latest Report”) = VRLDTMar.AsEnumerable().Count(Function(row) row.Field(Of String)(“Email Received”) = "Yes" AndAlso row.Field(Of String)(“Latest Report”) = "Yes")


1 Like

Hi @Amol_Golhar

Check the below image for better understanding:

=> Build Data Table


Output-> dt

=> Use the below syntax in Assign:

countYes = dt.AsEnumerable().Count(Function(row) row.Field(Of String)("Email Received").Equals("Yes") AndAlso row.Field(Of String)("Latest Report").Equals("Yes"))

countYes is of DataType System.Int32

Hope it helps!!

1 Like

Hi @Amol_Golhar

Try this:

VRLDTMar.AsEnumerable.Count(Function(row) row.Field(Of String)("Email Received").ToLower.Equals("yes") AndAlso row.Field(Of String)("Latest Report").ToLower.Equals("yes"))

Hope it will helps you :slight_smile:
Cheers!!

1 Like

Hi @Amol_Golhar

Try this

AddRow(“Emails Received”) = VRLDTMar.AsEnumerable().Count(Function(row) row.Field(Of String)(“Email Received”) = “Yes” AndAlso row.Field(Of String)(“Latest Report”) = “Yes”)

1 Like

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