Skip to content

Commit

Permalink
fix SummarizeValues average value
Browse files Browse the repository at this point in the history
  • Loading branch information
spacefreak86 committed Nov 30, 2024
1 parent 00788b3 commit 22bbd2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/expr/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,16 @@ func SummarizeValues(f string, values []float64, absent []bool) (float64, bool,
rv += av
}
case "avg", "average":
total := 0
for i, av := range values {
if !absent[i] {
rv += av
total++
}
}
rv /= float64(len(values))
if total > 0 {
rv /= float64(total)
}
case "max":
rv = math.Inf(-1)
for _, av := range values {
Expand Down

0 comments on commit 22bbd2c

Please sign in to comment.