Report data from datatable

I have the following data set within a data table called i_dt:

Region Status
North Failed
South Pass
South Pass
South Pass
West Pass
West Failed

I would like the output to look like this, with a total processed (count of Pass and fails for each row):

Region Pass Failed Count
North 0 1 1
South 3 0 3
East 0 0 0
West 1 1 2

Can this be done with linq?

In general we would group the data by the Region Status and process the groupmembers

Hi @Newbie_23

Check out the Below Workflow. It will help you.

Sequence14.xaml (17.5 KB)


Thank you but the file is showing a corrupt error - unable to open file. Can you zip the full file and try to upload that?

Thanks @ppr

I tried to use the article as guidance but got lost in trying to add select where = within a Let for reporting on status

share some more details on what was done

Also keep in mind that in the begin also a Non-LINQ Approach is presented

I have tried to do something like this, but syntax is not correct

(From d In i_dt.AsEnumerable
Group d By k=d(“Region”).toString.Trim Into grp=Group
Let p = grp.Count where (“Status”).equals(strPass)
Let f = grp.Count where (“Status”).equals(strFailed)
Let r = New Object(){k, p, f}
Select i_dtOut.Rows.Add(r)).CopyToDataTable

Some essential Syntax rules were to correct e.g. like

(From d In i_dt.AsEnumerable
Group d By k=d("Region").toString.Trim Into grp=Group
Let p = grp.Where(Function (p) p("Status").ToString.Equals("Passed")).Count
Let f = grp.Where(Function (f) f ("Status").ToString.Equals("Failed")).Count
Let r = New Object(){k, p, f}
Select  r = i_dtOut.Rows.Add(r)).CopyToDataTable
1 Like

Thank you for your help

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