Downsample a year of data by weeks and month

Hello,

we use InfluxDB for a research project where we import a CVS file containing time series data from 1 year starting at the 1. of February 2015 until 31. January 2016 of the next year with a interval of 1 hour.

We want to downsample the data by days, weeks, months and year. Day and year works as expected and gives as the same results as when we use Excel but weeks and month not. The computed sum is wrong for each record. Here are the queries we ran for down sampling:

// days
select sum(value) as value from m1 group by time(1d)
// week
select sum(value) as value from m1 group by time(1w)
// month
select sum(value) as value from m1 group by time(4w)
// year
select sum(value) as value from m1

Strangely the time of the first record in week and month is always previous the first time entry of the raw data.

1 Like

I would suggest exploring the offset function. By default it will use the Influx computed start and end times but with offset you can move the calculation start time/end time

e.g. the below will move the query by a day
select sum(value) as value from m1 group by time(1w,1d)