# Find average of max in each bucket

**URL:** <https://discuss.elastic.co/t/find-average-of-max-in-each-bucket/175934>\
**Category:** Kibana\
**Created:** [April 9, 2019, 1:19am UTC](https://discuss.elastic.co/t/find-average-of-max-in-each-bucket/175934 "2019-04-09T01:19:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Natalia\_Kuleniuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/natalia_kuleniuk/32/43727_2.png) [@Natalia\_Kuleniuk](https://discuss.elastic.co/u/Natalia_Kuleniuk)\
**Post date:** [April 9, 2019, 1:19am UTC](https://discuss.elastic.co/t/find-average-of-max-in-each-bucket/175934/1 "2019-04-09T01:19:30Z")

</div>

Hi, having trouble using Sibling aggregation in Kibana ()

I have records like following:

```
{

“EventId”: “123”,

“intPayloadNumber”: 234,

“someField”: “someValue”

}

```

I can have multiple records in Kibana for the same eventId.

**What I need to do is find average of max intPayload across all events:**

**Step 1:** For each eventId, I need to find MAX value of intPayload field (Each eventId may have multiple intPayloads values).

**Step 2:** And then, find AVERAGE of result of Step 1 (Average of MAX across all eventIds)

I need to display it as single value on dashboard.

To do so, I selected **Metric Visualization** -\> then in Metrics I selected **“Average bucket”** aggregation.

After that, in **“Bucket “** tab, I selected **Terms** aggregation and specified my **eventId** field (basically, I assume it means group by eventId).

Then, in **Metric tab** , I selected **“Max”**  **Aggregation** for **“eventId”**  **Field**.

However, the result I see doesn’t match expected result.  
Also, in Bucket -\> Aggregation tab, I am confused with Size field: when I increase it - my result is also changing (I expect to see all eventIds being included in my aggregation)

 ![02%20PM](https://us1.discourse-cdn.com/elastic/original/3X/d/c/dc2a3462d5224a389c2972eaa3e08a31d543ecd9.png) ![11%20PM](https://us1.discourse-cdn.com/elastic/original/3X/4/2/422d4df704f59abf1634486a10b1ca8f4ee2141e.png)

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [April 12, 2019, 4:13pm UTC](https://discuss.elastic.co/t/find-average-of-max-in-each-bucket/175934/2 "2019-04-12T16:13:32Z")

</div>

Can you also try with this kind of setup in Visual Builder to see if you get the expected results?

 ![visual_builder](https://us1.discourse-cdn.com/elastic/original/3X/e/b/ebb6caa78be082efdeffc722f0d7fc570ec9cdb5.png)

---

<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:** [May 10, 2019, 4:13pm UTC](https://discuss.elastic.co/t/find-average-of-max-in-each-bucket/175934/3 "2019-05-10T16:13:40Z")

</div>

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