Query for group the values

Input-Datatable

Filename. Status
File1 success
File2 success
File1 success
File3 success
File2 success
File2 Success
File3 Failed
File3 Failed

Output-Datatable
Filename status count
File1 Success 2
File2 Success 3
File3 Success 1
File3 Failed 1

Need query to get this output

Hi @Demo_User

Please give the following query a try:

outputDt = (From row In inputDt.AsEnumerable()
            Group row By key = New With {
                Key .Filename = row.Field(Of String)("Filename"),
                Key .Status = row.Field(Of String)("Status")
            } Into Group
            Select outputDt.Rows.Add(key.Filename, key.Status, Group.Count())).CopyToDataTable()

Hope this helps,
Best Regards.

Getting object not set to instance of object

@Demo_User

Please declare the data table outputDt & then proceed with the assignment.

Best Regards.

Yes it is in datatable format

@Demo_User

Please send the workflow screenshot & error message description. Also, make sure you are using the correct column names as per your source data.

Best Regards.

Any updates

Its working thanks

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