# Cut off first "pro rata row" after aggregateWindow

**URL:** <https://community.influxdata.com/t/cut-off-first-pro-rata-row-after-aggregatewindow/23250>\
**Category:** InfluxDB 2\
**Tags:** flux\
**Created:** [January 6, 2022, 8:50am UTC](https://community.influxdata.com/t/cut-off-first-pro-rata-row-after-aggregatewindow/23250 "2022-01-06T08:50:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![frank2604](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@frank2604](https://community.influxdata.com/u/frank2604)\
**Post date:** [January 6, 2022, 8:50am UTC](https://community.influxdata.com/t/cut-off-first-pro-rata-row-after-aggregatewindow/23250/1 "2022-01-06T08:50:09Z")

</div>

I store the energy consumption of devices per hour at the end of each hour.

Now I want to display an aggregation of the consumption of the last 7 days. The time should be relative, so `start: -7d.`

In this case the first record is only pro rata and not the whole day:

 ![Flux 1](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/4/4a51081c3497bab81a4c56bdb88a11c312d4515a.jpeg)

But I want to start with a whole day.

I have managed a solution with “start: -8d & sort desc → limit n:7 → sort asc”:

```auto
> from(bucket: "iobroker")
> |> range(start: -8d)
> |> filter(fn: (r) => r["_measurement"] == "Strom.Heizung.Energie_in_der_letzten_Stunde")
> |> drop(columns: ["_field", "ack", "from"])
> |> aggregateWindow(every: 1d, fn: sum, createEmpty: false)
> |> timeShift(duration: -1s)
> |> sort(columns: ["_time"], desc: true)
> |> limit(n:7)
> |> sort(columns: ["_time"], desc: false)

```

This works, but it looks a bit messy and not very elegant. Is there a better way?

Thanks

Frank
