# Scripted Aggregations in Time Series Visual Builder

**URL:** <https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388>\
**Category:** Kibana\
**Created:** [September 5, 2017, 8:35am UTC](https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388 "2017-09-05T08:35:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hetzer-fastec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hetzer-fastec/32/21809_2.png) [@hetzer-fastec](https://discuss.elastic.co/u/hetzer-fastec)\
**Post date:** [September 5, 2017, 8:35am UTC](https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388/1 "2017-09-05T08:35:25Z")

</div>

Right now, one can neither select a scripted field as the target of an aggregation nor supply a custom script in combination with a special aggregation in the time series visual builder, as far as I see. Is that correct?

I have a use case where I need to compute several bucket script aggregations over simple aggregations, which themselves are scripted. For example: I need to compute a sum of the form sum(f(x)), where f(x) = x, if y = 0 and f(x) = 0 else (x, y are document fields). Generally I have an ES query which computes exactly this value. Nevertheless it seems that I am not able to visualize this in Kibana.

Is there any way I can use a scripted aggregation (e.g. scripted sum aggregation) as a child aggregation of a bucket script aggregation in Kibana?

Unfortunately I am not in a situation to alter the type in order to include an according precomputed field.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 5, 2017, 7:17pm UTC](https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388/2 "2017-09-05T19:17:46Z")

</div>

TSVB does not support scripted fields.

TSVB does support scripted aggregations such as [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html)

---

<div class="post-metadata">

**Author:** ![hetzer-fastec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hetzer-fastec/32/21809_2.png) [@hetzer-fastec](https://discuss.elastic.co/u/hetzer-fastec)\
**Post date:** [September 11, 2017, 6:22am UTC](https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388/3 "2017-09-11T06:22:35Z")

</div>

Thanks for your answer, Nathan.

In that case I will submit a feature request 🙂. Just wanted to make sure that I am not missing some functionality.

Nevertheless your answer is not 100% correct, as far as I know, as the TSVB supports the bucket script aggregation since 5.4 (see [https://github.com/elastic/kibana/issues/4707](https://github.com/elastic/kibana/issues/4707) - answer by tbragin at the very bottom).

---

<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 9, 2017, 6:22am UTC](https://discuss.elastic.co/t/scripted-aggregations-in-time-series-visual-builder/99388/4 "2017-10-09T06:22:40Z")

</div>

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