# Strange Avg Aggregation Behaviour

**URL:** https://discuss.elastic.co/t/strange-avg-aggregation-behaviour/55322
**Category:** Elasticsearch
**Created:** [July 12, 2016, 3:33pm UTC](https://discuss.elastic.co/t/strange-avg-aggregation-behaviour/55322 "2016-07-12T15:33:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![daniel-burke](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@daniel-burke](https://discuss.elastic.co/u/daniel-burke)
#### Post date: [July 12, 2016, 3:33pm UTC](https://discuss.elastic.co/t/strange-avg-aggregation-behaviour/55322/1 "2016-07-12T15:33:19Z")

</div>

I'm seeing strange behaviour when using the aggregations against a number field - avg, max etc  
Given this result set:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/c/c509d56dc625623bd82145a357224e74ae5c5497.png)

I'd expect to be able to generate visualisations against the max of these values or the average. The behaviour I'm seeing is that aggregation requests always return zero?  
Here's a sample request and response:

```auto
{
  "size": 0,
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "query": "*",
          "analyze_wildcard": true
        }
      },
      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "StartTime": {
                  "gte": 1468191600000,
                  "lte": 1468277999999,
                  "format": "epoch_millis"
                }
              }
            }
          ],
          "must_not": []
        }
      }
    }
  },
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "StartTime",
        "interval": "10m",
        "time_zone": "Europe/London",
        "min_doc_count": 1,
        "extended_bounds": {
          "min": 1468191600000,
          "max": 1468277999999
        }
      },
      "aggs": {
        "1": {
          "max": {
            "field": "TotalErrorPercentage"
          }
        }
      }
    }
  }
}

```

```auto
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 30,
    "successful": 30,
    "failed": 0
  },
  "hits": {
    "total": 36,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": [
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T07:20:00.000+01:00",
          "key": 1468218000000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T07:30:00.000+01:00",
          "key": 1468218600000,
          "doc_count": 12
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T07:40:00.000+01:00",
          "key": 1468219200000,
          "doc_count": 5
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T07:50:00.000+01:00",
          "key": 1468219800000,
          "doc_count": 4
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T08:00:00.000+01:00",
          "key": 1468220400000,
          "doc_count": 6
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T08:10:00.000+01:00",
          "key": 1468221000000,
          "doc_count": 6
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2016-07-11T08:20:00.000+01:00",
          "key": 1468221600000,
          "doc_count": 2
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [July 13, 2016, 3:26pm UTC](https://discuss.elastic.co/t/strange-avg-aggregation-behaviour/55322/2 "2016-07-13T15:26:24Z")

</div>

Maybe the max is actually 0 on all these buckets? If not can you build a simple recreation of the issue (including index creation and indexing documents) so that we can look into it?

---

<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: [July 5, 2017, 10:35pm UTC](https://discuss.elastic.co/t/strange-avg-aggregation-behaviour/55322/3 "2017-07-05T22:35:57Z")

</div>


