Data table dynamic code issue

Hello,

My scenario is : I have a data table where i have values in 2 rows and 3 columns as follows
Name Mon Tue Wed
Anita P A H
Sam P P H
John A H A
The bot has to check how many p are there in a row and calculate its occurrence means if it 1 time , 2 time and then return the name who has P value in their row.
How can i do this ? I tried several ways i am able to fetch name value but not total value. Please suggest on this.

Thank you.

Hi,

How about the following?

Main.xaml (8.6 KB)

Regards,

2 Likes

yes this is working. Thank you so much @Yoichi

1 Like

Can you suggest from where to read about data table, functions used in it, its syntax as i can see you have used this enumerable here . I am not aware of all these functions. Please suggest so that i can have an idea about data tables for my future references @Yoichi

Hi,

It’s LINQ expression. It mainly consists of 3 method : ToDictionary, Cast and Count.
In this case, it returns dictionary which are name as key and number of “P” as value.
ToDictionary method returns dictionary from IEnumerable<T> ( in this case it’s DataRow array).
Function(r) r(0).ToString returns content of name column of the row. it will be key of dictionary.
Function(r) dt.Columns.Cast(Of DataColumn).Count(Function(c) r(c).ToString="P") returns count of “P” in each column of the row.

The following topic might also help you.

Regards,

1 Like

Thank you for sharing. I will go through these links.

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