Get total count of data based on group by condition in Datatable


I am having a datatable like this:

Id Name Result
1 MyApp1 Pass
1 MyApp1 Fail
2 MyApp1 Pass
2 MyApp2 Fail
5 MyApp2 Fail

I need to extract three informations out here

Id Name and total number of Pass/Fail

in this case:
O/p is

Id Name Total Number of Pass case
1 MyApp 1
2 MyApp1 2

Basically group by records based on ID here

You can use filter data table activity.

Hey @KannanSuresh - Filter DataTable applies filter on Rows Values. Here I have to apply a group by function in LINQ to existing datatable to get total count of group by column having specific value.

Pls have a look in my stated example and suggest how this can be achieved using datatable.

Let me know if any info is required for this.

Hi @p4uk80

Either you can use Filter Data Table Activity or
you can loop it using for each activity

  • Read the excel and clone it to the new datatable like DataTable new_Dt = oldDataTable.clone()
  • row(2).ToString.Contains(“Pass”)
  • Use invoke method activity, having Import Row as a MethodName
  • For a target property inside Invoke Method Activity assign new datatable variable

Goutham Vijay

Thanks @GowthamSelvaraj. However I need total count also in the datatable.

I mean Total number of pass cases in 3 rd column. So for every name there are multiple rows in Datatable 1 and in datattable 2 I need one row only.

Id, Name and Total number of Pass cases

Id Name Total Number of Pass case
1 MyApp 1
2 MyApp1 2


FYI, you have tagged a wrong person,

Refer the following program,
_Test.xaml (11.9 KB)
Sample.xlsx (9.2 KB)



Thank you for this @GouthamVijay! It really helps me!

Thanks, please mark it as a solution. It helps.

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