# Try to get the data from one day

**URL:** https://community.influxdata.com/t/try-to-get-the-data-from-one-day/56242
**Category:** InfluxDB 2
**Tags:** influxdb, flux
**Created:** [February 2, 2025, 3:07pm UTC](https://community.influxdata.com/t/try-to-get-the-data-from-one-day/56242 "2025-02-02T15:07:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nicolas\_Lauinger](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nicolas_lauinger/32/15636_2.png) [@Nicolas\_Lauinger](https://community.influxdata.com/u/Nicolas_Lauinger)
#### Post date: [February 2, 2025, 3:07pm UTC](https://community.influxdata.com/t/try-to-get-the-data-from-one-day/56242/1 "2025-02-02T15:07:58Z")

</div>

Hi guys,  
i do this query

```auto
from(bucket: "Solaranlage-Short-Term")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Consumption")
  |> filter(fn: (r) => r["host"] == "TotalSelfConsumption")
  |> filter(fn: (r) => r["_field"] == "TotalSelfConsumption")
    |> aggregateWindow(every: 1d, fn: (tables=<-, column) => tables
      |> integral(unit: 1s),
      createEmpty: false
  )
  |> map(fn: (r) => ({ r with _value: r._value / 3600.0 }))
  |> filter(fn: (r) => exists r._stop)  
  |> yield(name: "daily_consumption_kWh")
  

```

I would expect to get exactly one data point. But I get two. The second value 23.2566… is the correct one.  
I set the time range from 2025-02-02 00:00:00 to 2025-02-02 15:50:54 (The day so far.)

Does anyone have any idea what I am doing wrong?

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2f4110faee071361340afd01ec795967c083e667.png)

Cheers

---

<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: [February 3, 2025, 11:10pm UTC](https://community.influxdata.com/t/try-to-get-the-data-from-one-day/56242/2 "2025-02-03T23:10:13Z")

</div>

Hello @Nicolas_Lauinger,

```auto
import "array"
data = array.from(rows: [{_time: 2025-02-02T00:00:00Z, _value: 1.0},{_time: 2025-02-02T15:50:54Z, _value: 2.0}])

data
  |> range(start: 2025-02-02T00:00:00Z, stop: 2025-02-02T15:50:54Z)
  |> aggregateWindow(every: 1d, fn: (tables=<-, column) => tables
      |> integral(unit: 1s),
      createEmpty: false
  )
  |> map(fn: (r) => ({ r with _value: r._value / 3600.0 }))
  |> filter(fn: (r) => exists r._stop)  
  |> yield(name: "daily_consumption_kWh")

```

This worked for me. I’m not sure what’s happening.

This helps explain the behavior of aggWindow()

> <https://github.com/influxdata/flux/issues/1730>
>
> When using the \`aggregateWindow\` function, it will set all the outputted records… \`\_start\` and \`\_stop\` columns to the value set in the \`range\` function. This behavior differs from that of \`window\`. \`window\` sets the \`\_start\`and \`\_stop\` to the start and stop for the window for that particular record. This difference is confusing and doesn't seem like it should be the default. 
> 
> I propose changing the \`\_start\` and \`\_stop\` values for the outputted columns to the start and stop of an individual row's window. An option can be added to \`aggregateWindow\` to allow the user to pass in the columns they want the final \[\`window\` function call\](https://github.com/influxdata/flux/blob/222b98ef1a9c4ffefc1acedd714c7b1f8f007446/stdlib/universe/universe.flux#L116) to output its \`\_start\` and \`\_stop\` to.

Can you verify that the problem is a range agg window conflict by adding:

```auto
from(bucket: "Solaranlage-Short-Term")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Consumption")
  |> filter(fn: (r) => r["host"] == "TotalSelfConsumption")
  |> filter(fn: (r) => r["_field"] == "TotalSelfConsumption")
    |> aggregateWindow(every: 1d, fn: (tables=<-, column) => tables
      |> integral(unit: 1s),
      createEmpty: false
  )
  |> yield(name: "after aggwindow") 
  |> group()
  |> yield(name: "after group") 
  |> map(fn: (r) => ({ r with _value: r._value / 3600.0 }))
  |> filter(fn: (r) => exists r._stop)  
  |> yield(name: "daily_consumption_kWh")

```

And seeing if there are two tables in the after aggwindow result and if a group fixes it?

---

<div class="post-metadata">

### Author: ![Nicolas\_Lauinger](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nicolas_lauinger/32/15636_2.png) [@Nicolas\_Lauinger](https://community.influxdata.com/u/Nicolas_Lauinger)
#### Post date: [February 6, 2025, 10:43pm UTC](https://community.influxdata.com/t/try-to-get-the-data-from-one-day/56242/3 "2025-02-06T22:43:51Z")

</div>

This is the result of your query.

 ![result](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/6/6/6610cb9b8156db77351d4ba40846cb00d20be7d6.png)
