Como calcular min de una columna segun grupo
Publicado por Miguel (15 intervenciones) el 29/04/2020 02:34:50
Estimados,
Previos saludos, tengo la siguiente duda:
DatagridView3
C0 ! C1
aa ! 0.2
aa ! 1
bb ! 4
bb ! -1
DatagridView1
C0 ! C1 !
aa ! Resultado MIn=0.2
bb ! Resultad0 Min = -1
Estoy haciendo lo siguiente, sin embargo no me entrega el resultado esperado:
De ante mano muchas gracias por su ayuda.
Previos saludos, tengo la siguiente duda:
DatagridView3
C0 ! C1
aa ! 0.2
aa ! 1
bb ! 4
bb ! -1
DatagridView1
C0 ! C1 !
aa ! Resultado MIn=0.2
bb ! Resultad0 Min = -1
Estoy haciendo lo siguiente, sin embargo no me entrega el resultado esperado:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Dim IDi As String
For DGV1 As Integer = 0 To DataGridView1.Rows.Count - 1
IDi = DataGridView1.Item(0, DGV1).Value
For DGV3 As Integer = 0 To DataGridView3.Rows.Count - 1
If DataGridView3.Item(0, DGV3).Value = IDi Then
Dim valorMaximo As Double = 0
Dim valorMinimo As Double = Double.MaxValue
For Each row As DataGridViewRow In DataGridView3.Rows
If Not row.IsNewRow Then
If row.Cells(0).Value > valorMaximo Then
valorMaximo = row.Cells(0).Value
End If
If row.Cells(0).Value < valorMinimo Then
valorMinimo = row.Cells(0).Value
End If
End If
Next
If DataGridView3.Item(1, DGV3).Value = valorMinimo Then
DataGridView1.Item(1, DGV1).Value = DataGridView3.Item(1, DGV3).Value
Else
End If
Else
End If
Next
Next
De ante mano muchas gracias por su ayuda.
Valora esta pregunta


0