Hi.
I am trying to Group and Sum some columns in a datatable and I have tried numerous ways to do this including LINQ, Dictionaries and other loops with no success. Wondering if someone smarter than me can point out a simply way to do it. This is what I have.
dtAttendeeList - This is a list of Attendees who attended the training.
dtAttendeeDetailed - This is a list of each attendee, the training session they attended, and the topics within the session and hours. Hours are recorded as Double (e.g 1.25) An attendee can attended multiple sessions so there are multiple records hence wanting to sum each row. The Topic hours can be blank or have a number. Not all sessions have time recorded for each topic. Everybody attending the same session will have the same hours.
format of dtAttendeeDetailed
Attendee Name, Session Name, Topic1Hours, Topic2Hours, Topic3Hours, Topic4Hours, Topic5Hours
example data:
Joe Blogs, Session 1, 1.0, 0, 0, 0, 0
Joe Blogs, Session 2, 0.25, 1.5, 0, 0, 1
Jill Blogs, Session 1, 1.0, 0, 0, 0, 0
I have a new Datatable created (dtAttendeeSummary) with the structure:
Attendee Name, Topic1Hours, Topic2Hours, Topic3Hours, Topic4Hours, Topic5Hours
This data will have been grouped by each Attendee and them sum each TopicHours column
end result for Joe Blogs would be:
Joe Blogs, 1.25, 1.5, 0, 0, 1
I want to loop through the dtAttendeeList and get the Attendee Name, then use that to match records in dtAttendeeDetailed, or if the data in dtAttendeeDetailed is simply grouped then I’ll get the results for each Attendee separately and use it for further processes.
Thank you in advance.