# No data found error when added new scripted field

**URL:** <https://discuss.elastic.co/t/no-data-found-error-when-added-new-scripted-field/218403>\
**Category:** Kibana\
**Created:** [February 7, 2020, 8:33pm UTC](https://discuss.elastic.co/t/no-data-found-error-when-added-new-scripted-field/218403 "2020-02-07T20:33:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajjithreddy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@sajjithreddy](https://discuss.elastic.co/u/sajjithreddy)\
**Post date:** [February 7, 2020, 8:33pm UTC](https://discuss.elastic.co/t/no-data-found-error-when-added-new-scripted-field/218403/1 "2020-02-07T20:33:36Z")

</div>

Hi,

I have a question regarding scripted filed in index patterns. My log stash event one of the column name is "model.size" and it's value is like "69147 Bytes". I am trying to convert this value into MBs. So I added a script in index pattern scripted field. When I tried to get my data nothing is populated, if I remove this script data is getting populated. I did not understand what is wrong with my script?

My script is:-

Name: Size\_MB  
Language: painless  
Type: String  
Format: default  
Script:  
if(doc['model.size'].value !=null) {  
return doc['model.size'].value / 1024 +'MB';  
}  
return "";

Please guide me if any thing wrong in the process or if any other way is there let me know.

Thanks in advance..!!

---

<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:** [February 11, 2020, 1:39pm UTC](https://discuss.elastic.co/t/no-data-found-error-when-added-new-scripted-field/218403/2 "2020-02-11T13:39:24Z")

</div>

It sounds like you are trying to display the value in `MB`. If that is the case, then setup a [field formatter](https://www.elastic.co/guide/en/kibana/current/field-formatters-numeric.html) for the field instead of using a scripted field. That way the value will be displayed in `MB` but there will be no [performance penalty for using a scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html).

 ![Screen Shot 2020-02-11 at 6.39.04 AM](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c903af3acfef663a5e6b2fd090d52155f28f475d.png)

---

<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 10, 2020, 1:39pm UTC](https://discuss.elastic.co/t/no-data-found-error-when-added-new-scripted-field/218403/3 "2020-03-10T13:39:26Z")

</div>

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