Hi all,
I am trying to get started with Flux (coming from influxQL), and having a hard time translating this simple influxQL query:
SELECT sum("east") - sum(eait) as "Soutirage / Injection", sum("pv") as "Prod PV" FROM $iota.autogen.energy WHERE $timeFilter GROUP BY time($kWh_interval,$tz_offset) fill(null)
Going through the docs I cam up with the following: map() generates the table I need in Grafana, however the initial 3 tables are still in the stream… is there any way I can get rid of them?
Setting _measurement = pv_summary and calling filter at the end is the best I could think of, but that seems to have no effect (I am using Explore Data in the Influxdb Web UI, Table view):
from(bucket: "iota-autogen")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "energy")
|> filter(fn: (r) => r["_field"] == "pv" or r["_field"] == "east" or r["_field"] == "eait")
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({_time: r._time, _measurement: "pv_summary", soutirage_injection: r.east - r.eait, pv: r.pv}))
|> filter(fn: (r) => r["_measurement"] == "pv_summary")
As a side question, is there really no way to obtain the pivoted table directly without having to call pivot, knowing that those fields all come from a single InfluxDB data point?