sensorname,timeline,humidity,lat,lng
New York,2022-06-22 18:53:06.387,34.4576,40.6943,-73.9249
Los Angeles,2022-06-22 18:52:52.860,10.4544,34.1141,-118.4068
Chicago,2022-06-22 18:52:32.863,14.6432,41.8375,-87.6866
Miami,2022-06-22 18:52:47.520,15.824,25.7840,-80.2101
from(bucket: "sensors")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensor_readings")
|> filter(fn: (r) => r._field == "humidity" or r._field == "sensorname" or r._field == "longitude" or r._field == "latitude")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> group()
|> drop(columns: ["_start", "_stop", "_time","_measurement"])
1 Like