# Groovy scripting to Add custom values to an aggregate result, Eg - Unique count of "field1" + 1

**URL:** <https://discuss.elastic.co/t/groovy-scripting-to-add-custom-values-to-an-aggregate-result-eg-unique-count-of-field1-1/105195>\
**Category:** Kibana\
**Created:** [October 25, 2017, 8:17am UTC](https://discuss.elastic.co/t/groovy-scripting-to-add-custom-values-to-an-aggregate-result-eg-unique-count-of-field1-1/105195 "2017-10-25T08:17:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![viswadeep](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@viswadeep](https://discuss.elastic.co/u/viswadeep)\
**Post date:** [October 25, 2017, 8:17am UTC](https://discuss.elastic.co/t/groovy-scripting-to-add-custom-values-to-an-aggregate-result-eg-unique-count-of-field1-1/105195/1 "2017-10-25T08:17:07Z")

</div>

How to add custom values to an aggregated result.

Eg - Unique count of "field1" + 1

Is this possible in Kibana?

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [October 25, 2017, 1:32pm UTC](https://discuss.elastic.co/t/groovy-scripting-to-add-custom-values-to-an-aggregate-result-eg-unique-count-of-field1-1/105195/2 "2017-10-25T13:32:34Z")

</div>

Hi,

Groovy as a scripting language is not recommended to use anymore and disabled by default.

Also scripted fields in Kibana only offer you the possibility to add fields to single documents, but there is currently no way to change the outcome of the aggregation.

If you just want to offset in visualization, maybe you should give Timelion a look. It has the ability to do math with constants (or even between time series), e.g.:

```auto
.es(metric=avg:field1).plus(1)

```

or

```auto
.es(metric=avg:field1).plus(.es(metric=avg:field2))

```

Cheers,  
Tim

---

<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:** [November 22, 2017, 1:32pm UTC](https://discuss.elastic.co/t/groovy-scripting-to-add-custom-values-to-an-aggregate-result-eg-unique-count-of-field1-1/105195/3 "2017-11-22T13:32:43Z")

</div>

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