I have a DataTable I would like massage into a new format (here is what it comes out like when attached to a gridview):
<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse: collapse;">
<tr>
<th scope="col">
Line
</th>
<th scope="col">
StartTime
</th>
<th scope="col">
EndTime
</th>
<th scope="col">
Attribute
</th>
<th scope="col">
Value
</th>
</tr>
<tr>
<td>
Line1
</td>
<td>
24/01/2013 7:30:10 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Actual
</td>
<td>
0
</td>
</tr>
<tr>
<td>
Line1
</td>
<td>
24/01/2013 7:30:10 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
ProductCategory
</td>
<td>
FFAC
</td>
</tr>
<tr>
<td>
Line1
</td>
<td>
24/01/2013 7:30:10 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Target
</td>
<td>
36.5
</td>
</tr>
<tr>
<td>
Line2
</td>
<td>
24/01/2013 7:26:50 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Actual
</td>
<td>
69
</td>
</tr>
<tr>
<td>
Line2
</td>
<td>
24/01/2013 7:26:50 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
ProductCategory
</td>
<td>
FFAC
</td>
</tr>
<tr>
<td>
Line2
</td>
<td>
24/01/2013 7:26:50 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Target
</td>
<td>
55.5555582046509
</td>
</tr>
<tr>
<td>
Line3
</td>
<td>
24/01/2013 8:00:20 AM
</td>
<td>
24/01/2013 8:47:50 AM
</td>
<td>
Actual
</td>
<td>
1475
</td>
</tr>
<tr>
<td>
Line3
</td>
<td>
24/01/2013 8:00:20 AM
</td>
<td>
24/01/2013 8:47:50 AM
</td>
<td>
ProductCategory
</td>
<td>
FFAC
</td>
</tr>
<tr>
<td>
Line3
</td>
<td>
24/01/2013 8:00:20 AM
</td>
<td>
24/01/2013 8:47:50 AM
</td>
<td>
Target
</td>
<td>
202.430557310581
</td>
</tr>
<tr>
<td>
Line4
</td>
<td>
24/01/2013 7:31:30 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Actual
</td>
<td>
1384
</td>
</tr>
<tr>
<td>
Line4
</td>
<td>
24/01/2013 7:31:30 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
ProductCategory
</td>
<td>
FFAC
</td>
</tr>
<tr>
<td>
Line4
</td>
<td>
24/01/2013 7:31:30 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Target
</td>
<td>
3179.26381587982
</td>
</tr>
<tr>
<td>
Line5
</td>
<td>
24/01/2013 7:37:00 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Actual
</td>
<td>
0
</td>
</tr>
<tr>
<td>
Line5
</td>
<td>
24/01/2013 7:37:00 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
ProductCategory
</td>
<td>
FHHT
</td>
</tr>
<tr>
<td>
Line5
</td>
<td>
24/01/2013 7:37:00 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Target
</td>
<td>
92.6652171770756
</td>
</tr>
<tr>
<td>
P2_Bundler
</td>
<td>
24/01/2013 7:35:00 AM
</td>
<td>
24/01/2013 8:00:10 AM
</td>
<td>
Actual
</td>
<td>
7
</td>
</tr>
</table>
I know that if the records have the same line, start and end times, the records are related.
What I want to do is get a sum of the Actual and Target values grouped by the ProductCategory. In other words:
ProductCategory | Sum(Actual) | Sum(Target)
FFAC | 1000 | 2000
FHHT | 200 | 175
Any guidance would be appreciated!
Regards,
Chris