# Simple Scripted Field Error? (Kibana 4.1)

**URL:** <https://discuss.elastic.co/t/simple-scripted-field-error-kibana-4-1/62334>\
**Category:** Kibana\
**Created:** [October 6, 2016, 5:29am UTC](https://discuss.elastic.co/t/simple-scripted-field-error-kibana-4-1/62334 "2016-10-06T05:29:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allie\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/allie_yang/32/16538_2.png) [@Allie\_Yang](https://discuss.elastic.co/u/Allie_Yang)\
**Post date:** [October 6, 2016, 5:29am UTC](https://discuss.elastic.co/t/simple-scripted-field-error-kibana-4-1/62334/1 "2016-10-06T05:29:40Z")

</div>

I am creating a scripted field ' **popular**' as the division of two Integer fields as below:

if (doc['age'].value) \> 0  
doc['popular'].value = doc['o.nbd'].value / doc['age'].value;  
else  
doc['popular'].value = -1;

However, after i submitted, Kibana does not load the index anymore. **"There are errors in your input"**. After i delete the script field, it can load back again alright.

I am wondering if I have any errors in my script above?

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [October 7, 2016, 2:02pm UTC](https://discuss.elastic.co/t/simple-scripted-field-error-kibana-4-1/62334/2 "2016-10-07T14:02:51Z")

</div>

Hi Allie,

Try an expression like this;

```
(doc['age'].value) > 0 ? doc['o.nbd'].value / doc['age'].value : -1

```

Please let me know if this works.

Regards,  
Lee

---

<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:** [July 6, 2017, 1:37pm UTC](https://discuss.elastic.co/t/simple-scripted-field-error-kibana-4-1/62334/3 "2017-07-06T13:37:20Z")

</div>


