__timeGroup aggregation on ${Interval} - how to aggregate backward not forward?

Hi. I am trying to display data from postgres aggregated into time series.
However, an aggregation data point is always some relative date counting ${Interval} forward.
This gives me last data point on some relative date, which includes days in the future and always skew metrics. See attached picture, which was taken 02.02.2023. The previous point is 26.01.2023, which means that it aggregate data from 26.01.2023 to 02.02.2023. (7d interval) 02.02.2023 data point aggregate from 02.02.2023 to + {Interval} - which means next 6 days. Is there a possibility to aggregate backward rather than forward? To have 02.02.2203 aggregate from 26.01.2023 to 02.02.2023. In other words, from now-{Interval} to now and further data points similar?

Select statement:

  $__timeGroup("Closed", $__interval, 0) as "time", value
FROM table

I didn’t get you. Nobody is forcing you to use Grafana macro $__timeGroup. Write own SQL instead of that, which will fit your “backward aggregation” needs.

1 Like