# Additional column for fields in aggregate types

**URL:** https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987
**Category:** Kibana
**Created:** [September 26, 2018, 10:48am UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987 "2018-09-26T10:48:35Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nmccoy](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nmccoy](https://discuss.elastic.co/u/nmccoy)
#### Post date: [September 26, 2018, 10:48am UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/1 "2018-09-26T10:48:35Z")

</div>

I would like to use an aggregate to find the max of a value and show it in a table.

This works fine, but adding a column for a field in the aggregate is not so straightforward.

basically, can I display a .keyword for some bit of data in the document that is associated with the max?

---

<div class="post-metadata">

### Author: ![nmccoy](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nmccoy](https://discuss.elastic.co/u/nmccoy)
#### Post date: [September 26, 2018, 12:09pm UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/2 "2018-09-26T12:09:09Z")

</div>

here is an example, let's say i have a series of documents formatted like this:

```
{  
    "@timestamp":"<TIMESTAMP>",
    "tag":"<STRING_VALUE>",
    "value":"<FLOAT_VALUE>"
}

```

i would like to get a max aggregate of "value" but display "tag" somewhere in the visualisation somewhere

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [September 26, 2018, 6:57pm UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/3 "2018-09-26T18:57:06Z")

</div>

Hi there, here is a small demo I created using our sample data:

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

In this example I used a `Top Hit` aggregation to expose the `Carrier` field as a column in the table of max ticket prices per day. The `Carrier` field is analogous to the `tag` field in your example. Does this help give you an idea of how you can accomplish your goal?

Thanks,  
CJ

---

<div class="post-metadata">

### Author: ![nmccoy](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nmccoy](https://discuss.elastic.co/u/nmccoy)
#### Post date: [September 27, 2018, 10:15am UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/4 "2018-09-27T10:15:32Z")

</div>

This seems ok, but it does mean if i use the `Min` aggregation i will have to change the `Top hit` `Sort On` to `Ascending`. Correct?

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [September 27, 2018, 3:45pm UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/5 "2018-09-27T15:45:54Z")

</div>

Yes, I think that's right. And you'll want to change the "Sort on" field to sort on the field you're performing the `Min` aggregation on (`AvgTicketPrice` in my example, `value` in your case).

---

<div class="post-metadata">

### Author: ![nmccoy](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nmccoy](https://discuss.elastic.co/u/nmccoy)
#### Post date: [October 1, 2018, 8:13am UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/6 "2018-10-01T08:13:17Z")

</div>

ok thank you. this seemed to work.

---

<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: [October 29, 2018, 8:13am UTC](https://discuss.elastic.co/t/additional-column-for-fields-in-aggregate-types/149987/7 "2018-10-29T08:13:18Z")

</div>

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