# Aggregate with dynamic time range

**URL:** <https://discuss.elastic.co/t/aggregate-with-dynamic-time-range/322205>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [December 30, 2022, 10:02am UTC](https://discuss.elastic.co/t/aggregate-with-dynamic-time-range/322205 "2022-12-30T10:02:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedro123](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pedro123](https://discuss.elastic.co/u/pedro123)\
**Post date:** [December 30, 2022, 10:02am UTC](https://discuss.elastic.co/t/aggregate-with-dynamic-time-range/322205/1 "2022-12-30T10:02:05Z")

</div>

Hello,  
I am trying to create an aggregation based on a dynamic time frame which I want to calculate.  
I was trying to do something like this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/3/a31a23f7c082e4cde1070b3cd0b39a5b9e4694e1.png)

But I cant get it to work...  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 30, 2022, 11:54pm UTC](https://discuss.elastic.co/t/aggregate-with-dynamic-time-range/322205/2 "2022-12-30T23:54:07Z")

</div>

Please don't post pictures of text, logs or code. They are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 27, 2023, 11:54pm UTC](https://discuss.elastic.co/t/aggregate-with-dynamic-time-range/322205/3 "2023-01-27T23:54:46Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
