[ad_1]
I’m trying to sum the values of column11
, grouping by the value of column14
.
The table is like this:
column14 | column11 |
---|---|
014 | 10 |
014 | 20 |
013 | 5 |
013 | 20 |
014 | 5 |
017 | 15 |
My code looks like this, the result its close but the numbers are not right yet:
Edit*
Dim chartValues = New Dictionary(Of String, Integer)()
For Each row In DataGridView1.Rows.OfType(Of DataGridViewRow)
Dim column14Value = row.Cells().Item("Column14").Value.ToString()
Dim column11Value = row.Cells().Item("Column11").Value
If (chartValues.ContainsKey(column14Value)) Then
chartValues(column14Value) = chartValues(column14Value) + column11Value
Else
chartValues.Add(column14Value, column11Value)
End If
Next
For Each chartValue In chartValues
Chart1.Series(0).Points.AddXY(chartValue.Key, chartValue.Value)
Chart1.ChartAreas(0).AxisX.Interval = 1
Next
The result that I want is this:
column14 | column11 |
---|---|
014 | 35 |
013 | 25 |
017 | 15 |
Any help is really appreciated. Thanks!
[ad_2]