Hello @Ravikant_Gautam,
For me to help you I think it might be easier if you can explain what you’re trying to do?
It looks like you’re trying to find the difference between the max and min value in a table right for one field? or across all fields?
data = from(bucket: "my-bucket")
|> range(start: -5m)
|> filter(fn: (r) => r["_measurement"] == "cpu")
|> filter(fn: (r) => r["_field"] == "usage_system" or r["_field"] == "usage_user")
|> filter(fn: (r) => r["cpu"] == "cpu-total")
|> limit(n:3)
min =
data
|> min()
max =
data
|> max()
join(tables: {min: min, max: max}, on: ["_start"], method: "inner")
|> map(fn: (r) => ({ r with _value: r._value_max - r._value_min }))
The script above would calculate the max-min across fields.
Alternatively, this might be useful to you?