How to get absolute value with Query?

Hi, I’m studying Grafana with InfluxDB.
I want to change the measurement value to the absolute value.
How can I do this?
Someone says to use “SELECT * FROM * ~~~” but it doesn’t work.

My code is as follows.

Thanks for your help.

from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] =~ /${DEVICE:regex}/)
|> filter(fn: (r) => r[“_field”] == “current1” or r[“_field”] == “current2”)
|> aggregateWindow(every: v.windowPeriod, fn: mean)
|> yield(name: “mean”)

Try putting this before your yield statement:

|> map(fn: (r) => ({r with _value: math.abs(x: r._value)}))

You may also want to place the above statement before the aggregateWindow statement and see how your results change.

1 Like

Thank you so much. It works very well.