# Create conditional field based on aggregation in table view

**URL:** <https://discuss.elastic.co/t/create-conditional-field-based-on-aggregation-in-table-view/219962>\
**Category:** Kibana\
**Created:** [February 19, 2020, 12:26pm UTC](https://discuss.elastic.co/t/create-conditional-field-based-on-aggregation-in-table-view/219962 "2020-02-19T12:26:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dani\_Ruse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dani_ruse/32/54602_2.png) [@Dani\_Ruse](https://discuss.elastic.co/u/Dani_Ruse)\
**Post date:** [February 19, 2020, 12:26pm UTC](https://discuss.elastic.co/t/create-conditional-field-based-on-aggregation-in-table-view/219962/1 "2020-02-19T12:26:59Z")

</div>

Hello all,

I want to create a table with an "Error" column which will be populated with the values "YES" or "NO", depending on whether a sum aggregation has the value lower or greater than 0.

My metric looks as such:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/7/17331cefd4d5990464c8bd1ea45fb9453fd52bea.png)

The only problem is that I don't want to display the actual sum of errors, but I want to display YES if sum (error) \> 0 and "NO" otherwise.

Is there a way to do that in Kibana? Where should I insert this condition?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [February 19, 2020, 3:55pm UTC](https://discuss.elastic.co/t/create-conditional-field-based-on-aggregation-in-table-view/219962/2 "2020-02-19T15:55:45Z")

</div>

You can't do this in the Kibana Table visualization because it doesn't support bucket scripts like the one you are interested in doing. Here are your options:

- Write an ES SQL query in Kibana Canvas that can display this data
- Write a custom query and visualization in Vega
- Use a [Continuous Transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) to index pre-aggregated data, and then you can script against the pre-aggregated data

---

<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:** [March 18, 2020, 3:55pm UTC](https://discuss.elastic.co/t/create-conditional-field-based-on-aggregation-in-table-view/219962/3 "2020-03-18T15:55:46Z")

</div>

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