# InfluxDB2 Power Consumption Group by Month ?!?

**URL:** <https://community.grafana.com/t/influxdb2-power-consumption-group-by-month/77822>\
**Category:** InfluxDB\
**Created:** [December 11, 2022, 5:27pm UTC](https://community.grafana.com/t/influxdb2-power-consumption-group-by-month/77822 "2022-12-11T17:27:52Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![starfoxfs](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/starfoxfs/32/29112_2.png) [@starfoxfs](https://community.grafana.com/u/starfoxfs)\
**Post date:** [December 19, 2022, 12:12pm UTC](https://community.grafana.com/t/influxdb2-power-consumption-group-by-month/77822/15 "2022-12-19T12:12:46Z")

</div>

Hi @anon46745252,

here is my latest code:

```auto
from(bucket: "bucket1")
  |> range(start: -1mo, stop: now())
  |> filter(fn: (r) => r["_measurement"] == "power")
  |> filter(fn: (r) => r["_field"] == "todaykwh")
  |> aggregateWindow(every: 24h, fn: last, createEmpty: false)
  |> sum(column: "_value")
  |> duplicate(column: "_start", as: "_time")  
  |> aggregateWindow(every: 1mo, fn: last, period: 1mo)

```

This works, but I don’t know if a new bar will be created after this month, I hope so.

 ![1](https://us1.discourse-cdn.com/grafana/original/3X/4/5/45b86a87e51702e5645406413335bb1b6108930d.jpeg)

---

_[View the full topic](https://community.grafana.com/t/influxdb2-power-consumption-group-by-month/77822)._
