# Visualization empty for scripted field

**URL:** <https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348>\
**Category:** Kibana\
**Created:** [March 20, 2020, 5:11am UTC](https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348 "2020-03-20T05:11:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReenaN](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@ReenaN](https://discuss.elastic.co/u/ReenaN)\
**Post date:** [March 20, 2020, 5:11am UTC](https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348/1 "2020-03-20T05:11:30Z")

</div>

I have created a scripted field to get dayOfWeek from date field as below:  
if (doc['result.opened\_at'].size() != 0)  
{  
if (!doc['result.opened\_at'].empty) {  
doc['result.opened\_at'].value.dayOfWeek  
}  
}  
I could see the field created and populates the value in discover.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/be17091c63b18ba3da54414d55e39e5881a34ad6.png)

But in Kibana could not see the bar chart or any of the chart for the same scripted field.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/2/7203ab379ad739fbb376858a4bf50d8790a764d2.png)  
Not sure what I am missing here...

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [March 20, 2020, 11:08pm UTC](https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348/2 "2020-03-20T23:08:07Z")

</div>

Hi @ReenaN,

Couple questions for you:

1. What version of the stack are you running?
2. Could you please provide an example of the type of documents you are querying? Maybe just the `_source` for a few of them would be helpful.
3. And just to make sure I understood your question: you are seeing the field listed in discover with no issues, but when you try to do a terms aggregation against the field for the same timerange you see no results?

---

<div class="post-metadata">

**Author:** ![ReenaN](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@ReenaN](https://discuss.elastic.co/u/ReenaN)\
**Post date:** [April 3, 2020, 2:55am UTC](https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348/3 "2020-04-03T02:55:56Z")

</div>

Hi @lukeelmers,  
I have ElasticSearch on version 7.5.0. You got it right, in discover I see the field generated but in kibana term aggregate do not provide any result, shows blank graph

 ![Screenshot_2020-04-03 Discover - Kibana](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b9752f71d5c2ed827aeb90b7788b6fe4082d70ff.png) .  
I have created new field now as weekday\_open with the same definition.  
Attached is the source of one of the document.

---

<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:** [May 1, 2020, 2:56am UTC](https://discuss.elastic.co/t/visualization-empty-for-scripted-field/224348/4 "2020-05-01T02:56:04Z")

</div>

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