How to reverse a value?

Having googled a bit this link may be helpful. Calculate percentages with Flux | InfluxDB Cloud (TSM) Documentation.

Thank you, I already found that site a couple days ago but couldn’t figure out how to do it like described there.
I’ll have another look and see if I can understand now.

With flux being deprecated, do you know what the recommended method of querying in Grafana will be?

I honestly don’t know. In influx I go in my bucket, check my datapoint and click on script builder.
Then I have this code:

from(bucket: "boden-wz")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "monstera")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

That’ll just copy-paste in grafana.
Tbh I’m totally new to all this. I just followed some tutorials and failed around.
My target was to play through a tool chain to see if I can do it.
So I hope my answer helps a bit, I wish I could tell more.

Ok so in influx it makes sense I guess. I just don’t know how to name the value, everything I tried so far, failed.


  |> map(fn: (r) => ({ r with _value:  100.0 * (2850.0 - "_field") / (2850.0 - 1250.0) }))

Where did you put that? Before the aggregateWindow or after it?
Doesn't the yield at the end name it?

You would save influx a little time by using

{ r with _value: 0.0625 * (2850.0 - "_field")}

Yes, I put it right before that line.

It’s also just a string,:

  |> yield(name: "mean")

Just like that? Not the map before it?

  |> map(fn: (r) => ({ r with _value: 0.0625 * (2850.0 - "_field")})

It doesn’t matter btw if it’s field or mean, the error stays the same, it’s expecting an float but I have no idea what language that is, so I don’t know how to google how I convert that string

What else can the name be? I apparently don't understand what you mean by not knowing how to name it.

With the map, I was just suggesting a simpler formula to use (100/(2850-1250) is 0.0625)

You did not say there is an error, I thought it was working but with the wrong name against the line. What is the error?

Well, somehow I have to address the value or the variable it’s in. That’s what I meant with that.

Ah, sorry I didn’t get that before.


error @5:58-5:66: expected float but found string

OK, I understand. Try

 |> map(fn: (r) => ({ r with _value: 0.0625 * (2850.0 - r._value) })

That gives me a different error:

compilation failed: error @7:6-7:70: expected RPAREN, got EOF

Looks like you have lost a right parenthesis.
If you can't see it post the whole query here

Edit: there should be another one on the end.

Yes, now it looks pretty good!
Thank you very much! Hopefully will some noobs (as me) find this thread and get helpful informations. The beginning is pretty harsh!

Excellent

Der einfachste Weg ist vermutlich
image