# Monthly aggregation not working as expected

**URL:** https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184
**Category:** InfluxDB 2
**Tags:** flux
**Created:** [January 2, 2022, 11:00am UTC](https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184 "2022-01-02T11:00:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chris\_b](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@chris\_b](https://community.influxdata.com/u/chris_b)
#### Post date: [January 2, 2022, 11:00am UTC](https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184/1 "2022-01-02T11:00:16Z")

</div>

Hi,  
I’m trying to get monthly aggregations from values I record about every second. Unfortunately I’m struggling to get the query working correctly.  
I tried:

```auto
from(bucket: "mybucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "mymeasurement")
  |> filter(fn: (r) => r["_field"] == "myvalue")
  |> aggregateWindow(every: 1mo, fn: min)

```

I expected to get a result table with one entry for every month and a value from the beginning of the month (as I use the min function and the value is constantly growing as it is a meter reading).  
Infact I get the following (shortened to the relevant columns):

```auto
_time _value
2021-11-01T00:00:00Z	1361045.9416 # (that's a value from the end of September/beginning of oktober --> one month wrong)
2021-12-01T00:00:00Z	1431051.4897 # (that's a value from the end of October/beginning of November -> again one month wrong)
2022-01-01T00:00:00Z	1651448.4397 # (same here...)
2022-01-01T22:59:59Z	1935557.5113

```

All \_time values are wrong by one month. Why does this happen?

Thanks

---

<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: [January 4, 2022, 10:58pm UTC](https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184/2 "2022-01-04T22:58:29Z")

</div>

Hello @chris_b,  
What did you select for your start and stop times?

---

<div class="post-metadata">

### Author: ![chris\_b](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@chris\_b](https://community.influxdata.com/u/chris_b)
#### Post date: [January 10, 2022, 6:46pm UTC](https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184/3 "2022-01-10T18:46:07Z")

</div>

Hi @Anaisdg ,  
sorry for my late reply, I missed the email notification.  
On the Influx webfrontend I selected e.g. a range from 01.11.2021 00:00:00 to 01.01.2022 00:00:00 → always whole months. For some reason the “\_time” value is always one month to late compared to the expected result.

---

<div class="post-metadata">

### Author: ![chris\_b](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@chris\_b](https://community.influxdata.com/u/chris_b)
#### Post date: [January 10, 2022, 6:48pm UTC](https://community.influxdata.com/t/monthly-aggregation-not-working-as-expected/23184/4 "2022-01-10T18:48:54Z")

</div>

Would it help if I share some “real” data for the investigation? If so, how can I export the data in a helpful way?
