Summation of Hours per Employee

Good Day.

I have this datatable where it consists a list of employees together with their Employee IDs, Positions, Hours Rendered, and assigned Project Number. I want to find the summation of hours per employee just like the image below. Can I use Filter DataTable activity? Or are there any other activities that can be used? Thank you.

Kindly see attached file for the excel file.

Best regards,
Robert Monsalud
Sample1.xlsx (8.7 KB)

we would group the data:

1 Like

Thank you for the information. I will take a look on this.

Hi @Robert_Russell_Monsalud

As suggested by @ppr, this can be achieved through LINQ. Please refer the below screenshot and workflow files

(
	From row In dt_Data
	Group row By k = row("Employee ID")
	Into grp = Group
	Select dt_Data.LoadDataRow(grp(0).ItemArray.Reverse.Skip(1).Reverse.Append(grp.Sum(Function (gr) CInt(gr("Time Rendered")))).ToArray, True)
).CopyToDataTable

image

SummationOfHoursPerEmployee.xaml (5.6 KB)

2 Likes

Thank you so much for sharing the exact solution. May I ask if what are the further steps that I have to do if I will only retain the “Employee ID”, “Employee Name”, and “Time Rendered” column? Thank you.

Best regards,
Robert Monsalud

you can use afterwards e.g. filter datatable activity and keep / remove columns

1 Like

Hi @Robert_Russell_Monsalud

You can proceed like this

image

(
	From row In dt_Data
	Group row By k = row("Employee ID")
	Into grp = Group
	Select dt_Out.Rows.Add({k, grp(0)("Employee Name"), grp.Sum(Function (gr) CInt(gr("Time Rendered")))})
).CopyToDataTable

XAML for the reference

SummationOfHoursPerEmployee.xaml (7.0 KB)

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