# Error in Visualization with scripted field

**URL:** <https://discuss.elastic.co/t/error-in-visualization-with-scripted-field/189220>\
**Category:** Kibana\
**Created:** [July 6, 2019, 10:35pm UTC](https://discuss.elastic.co/t/error-in-visualization-with-scripted-field/189220 "2019-07-06T22:35:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucardo0](https://avatars.discourse-cdn.com/v4/letter/l/e8c25b/32.png) [@lucardo0](https://discuss.elastic.co/u/lucardo0)\
**Post date:** [July 6, 2019, 10:35pm UTC](https://discuss.elastic.co/t/error-in-visualization-with-scripted-field/189220/1 "2019-07-06T22:35:13Z")

</div>

Hi, i imported a csv file with a date column (Format example: '2019-05-01') and Kibana does not recognize it and read it like string.  
I tried to transform it with a scripted field:

> doc['Fecha'].value

I put date in the type and save successfully, but when i try to make a line chart, i got this error when a put in the X axis the new date created:

> Error in visualization
> 
> Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"aggregation\_execution\_exception","reason":"Unsupported script value [2019-05-01], expected a number, date, or boolean"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"easy\_aseos","node":"6qQvYLItTRqxT0zjGte05A","reason":{"type":"aggregation\_execution\_exception","reason":"Unsupported script value [2019-05-01], expected a number, date, or boolean"}}]},"status":500}

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [July 8, 2019, 4:17pm UTC](https://discuss.elastic.co/t/error-in-visualization-with-scripted-field/189220/2 "2019-07-08T16:17:17Z")

</div>

Can you share the mappings for the Fecha field? If it's a string and we want the scripted field to be a date we'll have to coerce it. Ideally the csv import is mapping the field as a date, but if not something like:

```auto
 new SimpleDateFormat('yyy-MMM-dd').parse(doc['Fecha'].value).getTime();

```

---

<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:** [August 5, 2019, 4:17pm UTC](https://discuss.elastic.co/t/error-in-visualization-with-scripted-field/189220/3 "2019-08-05T16:17:18Z")

</div>

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