Dual axis panel with timeshift in Grafana

Hello every one!
I need add panel for compare two test like on screenshot (actual test and 7 days ago test),
how i can do that?
Stack: Grafana and InfluxDB
image

Hello @opasnaya_britva
What version of InfluxDB are you using?
Is the data shifted in your screenshot?
If you are using v2 like your tag indicates, then you can use the following function timeShift() function | Flux Documentation
to help you move one series at the same timestamp as the other.

Does that help?

yea, i used it and have that


i just dont understand how to move this axis on one level :frowning:

that my queries

A:

from(bucket: "App")
  |> range(start: -1h)
  |> filter(fn: (r) => r["_measurement"] == "cpu")
  |> filter(fn: (r) => r["_field"] == "usage_idle")
  |> filter(fn: (r) => r["cpu"] == "cpu-total")  
  |> map(fn: (r) => ({ r with _value: r._value * -1.00 + 100.00 }))
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> group()
  |> rename(columns: {"_value": "Query А"})

B:

from(bucket: "App")
  |> range(start: -1h)
  |> filter(fn: (r) => r["_measurement"] == "cpu")
  |> filter(fn: (r) => r["_field"] == "usage_idle")
  |> filter(fn: (r) => r["cpu"] == "cpu-total")  
  |> timeShift(duration: -24h)
  |> map(fn: (r) => ({ r with _value: r._value * -1.00 + 100.00 }))
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> group()
  |> rename(columns: {"_value": "Query B"})

Hello @opasnaya_britva,
You’ll need to join the data.

If you want to perform math on data that’s now aligned.

But to use time shift correctly imagine:
data 1:

_ value | _time | 
         1 |  01/01
         2 |  01/02
         2 |  01/03

and data 2:

_ value | _time | 
         1 |  02/01
         4 |  02/02
         2 |  02/03

To align data1 forward to data2 you’ll have to do
timeShift(duration:1mo)
Because data2 is 1mo ahead of data1.
However notice that data1 and data2 have the same time frequency. If it’s important that the values line up exactly you might want to perform an aggegateWindow() before the timeshift to find a standardized timestamps before shifting.