# How to do date histogram again after date histogram aggregation?

**URL:** https://discuss.elastic.co/t/how-to-do-date-histogram-again-after-date-histogram-aggregation/225884
**Category:** Elasticsearch
**Created:** [March 31, 2020, 2:19pm UTC](https://discuss.elastic.co/t/how-to-do-date-histogram-again-after-date-histogram-aggregation/225884 "2020-03-31T14:19:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ziyang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ziyang/32/65430_2.png) [@ziyang](https://discuss.elastic.co/u/ziyang)
#### Post date: [March 31, 2020, 2:19pm UTC](https://discuss.elastic.co/t/how-to-do-date-histogram-again-after-date-histogram-aggregation/225884/1 "2020-03-31T14:19:49Z")

</div>

Now my aggregation is 5 min date histogram aggregation and then sum the result in every 5 min.

Now my DSL is similar to:

```json
{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "time": {
              "gt": "2020-03-31 11:30:00",
              "lt": "2020-03-31 13:00:00"
            }
          }
        },
        {
          "term": {
            "domain": "s3plus-shon.meituan.net"
          }
        }
      ]
    }
  },
  "aggs": {
    "flux_stats": {
      "date_histogram": {
        "field": "time",
        "interval": "5m",
        "format": "yyyy-MM-dd HH:mm:ss"
      },
      "aggs": {
        "flux": {
          "sum": {
            "field": "visit_flux"
          }
        }
      }
    }
  }
}

```

But I want to do date histogram sub aggregation again on the result, but the interval is 30 min and then find the max value in every 30 min, how can I do that?

---

<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: [April 28, 2020, 2:20pm UTC](https://discuss.elastic.co/t/how-to-do-date-histogram-again-after-date-histogram-aggregation/225884/2 "2020-04-28T14:20:13Z")

</div>

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