Get average percentage of data

Hey guys, i wanted to know if there is a good way to show the average % of increase or decrease over 24hours in my influxdb i am using Grafana to display everything. Is there a special command in grafana or in influxdb so i can query for it? Been trieng alot of stuff haven’t found a solution yet.

Example data would be:

hecMarketCap 280000 24hours ago

hecMarketCap 275000 1hour ago

I want to get the % of the decrease of them over 24Hours

Hello @Kliment,
Welcome. What version of InfluxDB are you using?
In Flux it would be something like:

import "math"
import "experimental"
import "array"

raw = array.from(rows: [{_time: experimental.subDuration(d: 1h, from: now()), _value: 280000.0},{_time: experimental.subDuration(d: 24h, from: now()), _value: 275000.0}])

firstPoint = raw 
  |> range(start: -24h)
  |> last() 
  |> findRecord(fn: (key) => true, idx: 0)

  |> range(start: -1h)
  |> map(fn: (r) => ({ r with percentDiff: math.abs(x: (firstPoint._value - r._value)/100.0) }))
  |> yield(name: "percent diff")