timeShift for ClickHouse time series

Grafana Version: 10.3.5

  • What are you trying to achieve?
    I have a timeseries graph with multiple items splittede by variable $timeSeries wich i use to select data from datetime field.
    I use the fillowing way to select data:
    select $timeSeries t code, count(*)
    from $table t
    where $timeFilter
    group by t, code
    order by t

  • How are you trying to achieve it?
    On top of that i need to add 7days timeshift separate query, however timeshift option apply on all of the queries and not only for the last one. So it does not work this way, unfortunatelly.

timeshift query should looks like this:
select $(some calculation with $Period variable to add 7days to datetime variable: t.created_at) t, ‘AllData-7D’ code, count(*)
from $table t
where $(something like this: t.created_at between date_add(day, -7, $from) and date_add(day, -7, $to)
group by t, code
order by t

  • What happened?
    Have no idea how to replace 2 variassbles correctly: $timeSeries and $timeFilter Need an assistance on that

  • What did you expect to happen?
    Expect to see additional data on the graph as a separate line.