How to transform values using map()

Hi,

from my temp sensors I receive values which I have to divide by 10 to get the correct degrees Celsius value. For instance my sensor delivers 190, but I want to have 19.0 to be shown on a dashboard.
Searching the docs I found the map() function. However, I’m not able to get it working.
My current query looks like this:

import “influxdata/influxdb/schema”
from(bucket: “hometest/autogen”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “rooms”)
|> filter(fn: (r) => r[“_field”] == “temp” or r[“_field”] == “id”)
|> schema.fieldsAsCols()
|> filter(fn: (r) => r[“id”] == 99954512588)
|> group(columns: [“id”])
|> aggregateWindow(every: v.windowPeriod, column: “temp”, fn: last)
|> yield()

Any idea how this can be implemented?

Hello @D_Kufner,
I find it helpful to use limit() and yield() to help you debug.
For example:

import “influxdata/influxdb/schema”
from(bucket: “hometest/autogen”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “rooms”)
|> filter(fn: (r) => r[“_field”] == “temp” or r[“_field”] == “id”)
|> limit(n:3)
|> schema.fieldsAsCols()
|> yield(name:  “after pivot “)
|> filter(fn: (r) => r[“id”] == 99954512588)
|> group(columns: [“id”])
|> aggregateWindow(every: v.windowPeriod, column: “temp”, fn: last)
|> yield()

For the map() I would do something like:

    |> map(fn: (r) => ({r with celcius: r.temp/10.0}))

Thanks a lot!
The map() function was where I struggled. That is working now.