Pivot key value to be column row?

Hello

Trying to query this data in influxdb via flux

name,time,host,topic,value
mqtt_consumer_float,1662507929695650760,vps-362a4be9,GPS/Latitude,43.5785
mqtt_consumer_float,1662507940992628730,vps-362a4be9,GPS/Longitude,1.44712

so that the final data looks like this

GPS/Latitude,GPS/Longitude
43.5785,.44712

Is this an issue of the data not being properly tagged/ingested into Influxdb?

Thanks

use pivot

from(bucket: “bucketName”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “xxx”)
|> pivot(rowKey: [“_measurement”], columnKey: [“topic”], valueColumn: “_value”)

1 Like

Thanks @sya

But I get the following error

runtime error @4:6-4:82: pivot: specified column does not exist in table: topic