'How to get _value of two tables into one table?
I'm trying to create a dashboard where i can filter data by gas station location and fuel type. This is my Table from this query:
from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["entity_id"] == "tankerkoenig_aral_tankstelle_bat_waldmohr_e5")
|> filter(fn: (r) => r["_field"] == "city_str" or r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: "last")
How can i get the _value of _field "city_str" and the _value of the _field "value" into one table so i can query the location and the price at the same time within grafana?
Solution 1:[1]
Use schema.fieldsAsCols function. You will get one table with city_str
and value
columns.
import "influxdata/influxdb/schema"
from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["entity_id"] == "tankerkoenig_aral_tankstelle_bat_waldmohr_e5")
|> filter(fn: (r) => r["_field"] == "city_str" or r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> schema.fieldsAsCols()
|> yield(name: "last")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |