# Result interpretation - Strange aggregate

**URL:** https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066
**Category:** InfluxDB 2
**Tags:** time, query, flux
**Created:** [December 21, 2021, 4:55pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066 "2021-12-21T16:55:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Monk](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Monk](https://community.influxdata.com/u/Monk)
#### Post date: [December 21, 2021, 4:55pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066/1 "2021-12-21T16:55:01Z")

</div>

I have following flux query:

```auto

import "date"
thisMonth = date.truncate(t: today(), unit: 1mo)

from(bucket: "home")
  |> range(start: thisMonth)
  |> filter(fn: (r) => r["_measurement"] == "vzlogger")
  |> filter(fn: (r) => r["Source"] == "S0_EG")
  |> filter(fn: (r) => r["_field"] == "Energy")
  |> aggregateWindow(every: 1d, fn: sum, createEmpty: false)

```

My intention is to get a daily sum across the current month, i.e. one daily total per day of the month.

 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/6/6a5fd19be13af318666644cf87877a72f18d9fb2.png)

Above is the screenshot from the InfluxDB UI.  
Why am I getting two lines of results for 2021-12-21 (current day)? How to avoid this?

Many thanks for any input and a happy holiday season

---

<div class="post-metadata">

### Author: ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)
#### Post date: [December 21, 2021, 5:02pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066/2 "2021-12-21T17:02:11Z")

</div>

@Monk aggregateWindow use the `_stop` column of each `1d` window as the new `_time` value of the aggregate points. So where “today” is still in progress, you get a partial window and that `_stop` time of the window is essentially `now()`. One thing to also note is that because it’s using the `_stop` time of each window as the new `_time`, the value is actually that of the previous day.

To solve this, I’d recommend specifying the `_start` as the `timeSrc` in `aggregateWindow()`:

```javascript
import "date"
thisMonth = date.truncate(t: today(), unit: 1mo)

from(bucket: "home")
  |> range(start: thisMonth)
  |> filter(fn: (r) => r["_measurement"] == "vzlogger")
  |> filter(fn: (r) => r["Source"] == "S0_EG")
  |> filter(fn: (r) => r["_field"] == "Energy")
  |> aggregateWindow(every: 1d, fn: sum, timeSrc: "_start", createEmpty: false)

```

---

<div class="post-metadata">

### Author: ![Monk](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Monk](https://community.influxdata.com/u/Monk)
#### Post date: [December 21, 2021, 5:23pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066/3 "2021-12-21T17:23:02Z")

</div>

@scott, many thanks, works like a charm. Still a lot to learn. Although I’m every time amazed by the power of InfluxDB, sometimes it feels like black magic. Thankfully there is such a supportive community.

---

<div class="post-metadata">

### Author: ![Monk](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Monk](https://community.influxdata.com/u/Monk)
#### Post date: [December 21, 2021, 5:35pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066/4 "2021-12-21T17:35:56Z")

</div>

@scott a related question if you allow:  
If I understand correctly, this would apply to all aggregates \> 1d?

---

<div class="post-metadata">

### Author: ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)
#### Post date: [December 21, 2021, 6:45pm UTC](https://community.influxdata.com/t/result-interpretation-strange-aggregate/23066/5 "2021-12-21T18:45:52Z")

</div>

@Monk Correct, it should.
