Hi, I’m new to flux, and I want to do this query, but it doesn’t work. I don’t know what I’m wrong about. The result that comes out is “NO RESULTS”:
importada = from(bucket: “energymeter”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “IMPORTADA”)
|> aggregateWindow(
every: 1h,
fn: (tables=<-, column) =>
tables
|> integral(unit: 1h)
|> map(fn: (r) => ({ r with _value: r._value})))
exportada = from(bucket: “energymeter”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “EXPORTADA”)
|> aggregateWindow(
every: 1h,
fn: (tables=<-, column) =>
tables
|> integral(unit: 1h)
|> map(fn: (r) => ({ r with _value: r._value})))
precioimportado = from(bucket: “energymeter”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “PRECIO_IMPORTADO”)
|> aggregateWindow(every: 1h, fn: last, createEmpty: false)
precioexportado = from(bucket: “energymeter”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “PRECIO_EXPORTADO”)
|> aggregateWindow(every: 1h, fn: last, createEmpty: false)
kWhresultantes = join(tables: {key1: importada, key2: exportada}, on: ["_time", “_field”], method: “inner”)
|> map(fn: (r) => ({
_time: r._time,
_value: ((r._value_key1 - r._value_key2)),
}))
precioimp = join(tables: {key3: precioimportado, key4: precioexportado}, on: ["_time", “_field”], method: “inner”)
|> map(fn: (r) => ({
_time: r._time,
_value: ((r._value_key3)),
}))
resultado = join(tables: {key5: kWhresultantes, key6: precioimp}, on: ["_time", “_field”], method: “inner”)
|> map(fn: (r) => ({
_time: r._time,
_value: ((r._value_key5 * r._value_key6)),
}))
|> yield()