Renaming Values

Hi all, I have a field called Status that will be either 0,1 or 2.

It represents the status of a machine where 0 = Ok , 1 = Warning and 2 = Error.

How do I display this in a stat?

from(bucket: "Connected Hydraulics")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "CytroPac")
  |> filter(fn: (r) => r["_field"] == "Status")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

Hello @subwayfootlong,
you can use conditional mapping:
Something like:

from(bucket: "Connected Hydraulics")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "CytroPac")
  |> filter(fn: (r) => r["_field"] == "Status")
  |> map(
          fn: (r) => ({r with
              Status: if r._value == 0 then
                  "Ok"
              else if r._value == 1 then
                  "Warning"
              else
                  "Error",
          }),

Please see