# How to simplify the following PromQL sentence？

**URL:** <https://discuss.prometheus.io/t/how-to-simplify-the-following-promql-sentence/897>\
**Category:** PromQL\
**Created:** [April 13, 2022, 9:04am UTC](https://discuss.prometheus.io/t/how-to-simplify-the-following-promql-sentence/897 "2022-04-13T09:04:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seraph\_v3](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@seraph\_v3](https://discuss.prometheus.io/u/seraph_v3)\
**Post date:** [April 13, 2022, 9:04am UTC](https://discuss.prometheus.io/t/how-to-simplify-the-following-promql-sentence/897/1 "2022-04-13T09:04:03Z")

</div>

Want to get the average day value of last 7 days or last 30 days like this:  
( (amount{area="$area",type="$type"} offset 1d) + (amount{area="$area",type="$type"} offset 2d) + (amount{area="$area",type="$type"} offset 3d) + (amount{area="$area",type="$type"} offset 4d) + (amount{area="$area",type="$type"} offset 5d) + (amount{area="$area",type="$type"} offset 6d)+ (amount{area="$area",type="$type"} offset 7d))/7

While I can use the above sentence for 7 days(and the query result graph is exactly what I expected), the sentence is too long for 30 days. Is there a way to use aggregate or something like loop to simplify that sentence?

---

<div class="post-metadata">

**Author:** ![SuperQ](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/superq/32/4_2.png) [@SuperQ](https://discuss.prometheus.io/u/SuperQ)\
**Post date:** [April 18, 2022, 9:10am UTC](https://discuss.prometheus.io/t/how-to-simplify-the-following-promql-sentence/897/2 "2022-04-18T09:10:02Z")

</div>

```auto
avg_over_time(amount{area="$area",type="$type"}[7d])

```
