# How to create new visualization using scripted field

**URL:** <https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936>\
**Category:** Kibana\
**Created:** [May 4, 2020, 8:00am UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936 "2020-05-04T08:00:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)\
**Post date:** [May 4, 2020, 8:00am UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/1 "2020-05-04T08:00:07Z")

</div>

HI Team,  
I have successfully generated number scripted field and i need to create visualization by using that field. whenever i try to achieve that way im getting below detail  
" No results displayed because all values equal 0." along with this error "1 of 5 shard failed". Im using version 6.4.0

Anyone can help me on this issue.

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [May 4, 2020, 9:37pm UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/2 "2020-05-04T21:37:26Z")

</div>

Can you check the simulation of the scripted field in the "edit/create scripted field" page? You can see there how it works on your documents.

---

<div class="post-metadata">

**Author:** ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)\
**Post date:** [May 5, 2020, 1:45pm UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/3 "2020-05-05T13:45:45Z")

</div>

> [@Marius\_Dragomir](#):
>
> Can you check the simulation of the scripted field in the "edit/create scripted field" page? You can see there how it works on your documents.

Please find my below image,

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/7/77f0feea275e82ad7fc0eda199b0f4c19d1dad1d.png)

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [May 5, 2020, 1:48pm UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/4 "2020-05-05T13:48:40Z")

</div>

It doesn't look like it's returning any values from the scripted field in that preview. Can look in more results to see if it does there?

---

<div class="post-metadata">

**Author:** ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)\
**Post date:** [May 5, 2020, 1:55pm UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/5 "2020-05-05T13:55:46Z")

</div>

HI,  
Currently, i've only one entry in my index and scripted field returning the userid from the message and please find my message and script for your reference,

`if (doc["data.keyword"].value != null){ def m = /UserID: ([0-9]+)/.matcher(doc["data.keyword"].value); if (m.find ()) { return m.group (1) } else { return "no match" } } else { return "NULL"}`

`2020-03-12 14:25:21:692 Logger - Received JSON Response: UserID: 624646, UserAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko`

---

<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:** [June 2, 2020, 2:08pm UTC](https://discuss.elastic.co/t/how-to-create-new-visualization-using-scripted-field/230936/6 "2020-06-02T14:08:20Z")

</div>

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