Hi, Thanks once again.
See to be some where I am missing syntax. can you please validate
import "date"
import "experimental/date/boundaries"
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
lastyear = from(bucket: "production")
|> range(start: 2023-01-01T00:00:00Z, stop: 2023-12-31T23:59:59Z)
|> filter(fn: (r) => r._measurement == "building")
|> filter(fn: (r) => r["deviceId"] == "B1-D00029")
|> filter(fn: (r) => r._field == "Value")
|> map(fn: (r) => ({
r with
month: date.month(t: r._time),
monthName: monthNames[date.month(t: r._time) - 1]
}))
|> group(columns: ["month"], mode: "by")
|> sum(column: "_value")
|> group()
thisyear = from(bucket: "production")
|> range(start: 2024-01-01T00:00:00Z, stop: 2024-12-31T23:59:59Z)
|> filter(fn: (r) => r._measurement == "building")
|> filter(fn: (r) => r["deviceId"] == "B1-D00029")
|> filter(fn: (r) => r._field == "Value")
|> map(fn: (r) => ({
r with
month: date.month(t: r._time),
monthName: monthNames[date.month(t: r._time) - 1]
}))
|> group(columns: ["month"], mode: "by")
|> sum(column: "_value")
|> group()
join.full(
left: lastyear,
right: thisyear,
on: (l, r) => l.month == r.month,
as: (l, r) => {
return {"This Year" : r._value, "Last Year" : l._value, month : l.month}
}
)
|> map(fn: (r) => ({
r with monthName: monthNames[r.month - 1]
}))
|> drop(columns : ["month"])
|> yield(name : "monthly_consumption")
Error
invalid: error @35:1-35:5: expected { A with full: ( as: (l: {B with month: D, _value: C}, r: {E with _value: F}) => {month: D, This Year: F, Last Year: C}, left: stream[G], on: (l: {H with month: I}, r: {J with month: K}) => bool, right: stream[L], ) => stream[{M with month: int}], } (record) but found (<-tables: N, ?method: string, ?on: [string]) => stream[O] (function)