How to negate bool value

I use Telegraf plugin inputs.net_response to check status of server TCP port. It returns result=success and have result_code=0i, which I plan use in Graph (Time series / State timeline) and also use Stat to see current status.

I can use transform to convert 0/1 (int) into Boolean, but 0 (success) become False (or OFF - when I change Unit), so I need negate it.
What is best way how to do it ? I’m using Grafana v8.4.4

sounds like you might want to try using value mapping:

Hi, yes, I currently use it, but it causes side effects to graphs, like decimal values in timeseries, or weird min/max in state timeline. This doesn’t happen with native bool values.
timeseries

timeline

I would say you need to use int type for graphing, especially if there is time aggregation (what is the mean value for true and false values - it doesn’t make sense).

I assume that you are using InfluxDB (because Telegraf). InfluxDB has many functions, which you can use for your “negation” (it is not real math negation, when we are talking about integers). If you are on InfluxDB 2.0+ then also flux has similar functions. You can use them and you can do a simple math, e.g.

ABS(field-1)

So field value 0 will have result 1 and field value 1 will have result 0.