# Dual axis panel with timeshift in Grafana

**URL:** <https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915>\
**Category:** InfluxDB 2\
**Tags:** influxdb, grafana, influxql, query, flux\
**Created:** [April 15, 2024, 3:13am UTC](https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915 "2024-04-15T03:13:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![opasnaya\_britva](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/opasnaya_britva/32/13972_2.png) [@opasnaya\_britva](https://community.influxdata.com/u/opasnaya_britva)\
**Post date:** [April 15, 2024, 3:13am UTC](https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915/1 "2024-04-15T03:13:33Z")

</div>

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](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/0/0b18fb38ff0407fb50f39554ee0f6b7f3c2212b4.png)

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [April 15, 2024, 4:27pm UTC](https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915/2 "2024-04-15T16:27:50Z")

</div>

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](https://docs.influxdata.com/flux/v0/stdlib/universe/timeshift/)  
to help you move one series at the same timestamp as the other.

Does that help?

---

<div class="post-metadata">

**Author:** ![opasnaya\_britva](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/opasnaya_britva/32/13972_2.png) [@opasnaya\_britva](https://community.influxdata.com/u/opasnaya_britva)\
**Post date:** [April 15, 2024, 5:53pm UTC](https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915/3 "2024-04-15T17:53:54Z")

</div>

yea, i used it and have that

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/d/de9fef2c06c89328cf09da14435d7e481554588e.png)  
i just dont understand how to move this axis on one level ☹

that my queries

A:

```auto
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:

```auto
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"})

```

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [April 16, 2024, 9:57pm UTC](https://community.influxdata.com/t/dual-axis-panel-with-timeshift-in-grafana/33915/4 "2024-04-16T21:57:27Z")

</div>

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

> **[join() function | Flux Documentation](https://docs.influxdata.com/flux/v0/stdlib/universe/join/)**
>
> join() merges two streams of tables into a single output stream based on columns with equal values. Null values are not considered equal when comparing column values. The resulting schema is the union of the input schemas. The resulting group key is...

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

But to use time shift correctly imagine:  
data 1:

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

```

and data 2:

```auto
_ 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.
