Hi I’m trying to get a value recalculated but it fails due to type differences.
My inserted data is of the type int and I want to become a float by dividing the sum of the integers.
import "date"
day = date.truncate(t: now(), unit: 1d)
from(bucket: "electricity")
|> range(start: day)
|> filter(fn: (r) =>
r["_measurement"] == "generated" and
r["_field"] == "AC power" and
r._value > 0
)
|> aggregateWindow(every: 1d, fn: sum, createEmpty: false)
|> map(fn: (r) => ({ r with _value: r._value / 3600 }))
|> toFloat()
|> map(fn: (r) => ({ r with _value: r._value /1000 *0.3 }))
When I try to run this query I get the type error:
type error @14:55-14:58: expected int but found float
edit:
If I change the last line to
|> map(fn: (r) => ({ r with _value: r._value /10000 * 3 }))
I get another error
type error @14:6-14:62: expected int but found float (argument tables)
Thx
Geoffrey