# Scripted field using 2 others scripted fields

**URL:** <https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185>\
**Category:** Kibana\
**Created:** [April 16, 2018, 12:00pm UTC](https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185 "2018-04-16T12:00:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![didinyah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/didinyah/32/30859_2.png) [@didinyah](https://discuss.elastic.co/u/didinyah)\
**Post date:** [April 16, 2018, 12:00pm UTC](https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185/1 "2018-04-16T12:00:09Z")

</div>

Hi,

Here's what I want to have in a DataTable visualization :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/6/06e0e7ad6a0e202c1869aaba47d6c8c476c5cbff.jpg)

I'm using 2 scripted fields :

- 1 to get the value of column Date1
- 1 to get the value of column Date2

For my third column, I would like to use the values that I get in both columns and do another script to calculate the values (it's the working days between the 2 dates)

Can I do it with the scripted fields ? Because in painless language I only saw "doc["my\_field"].value" but never "doc["my\_scripted\_field"].value

Is there a way to do it or am I doing it wrong ?

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [April 16, 2018, 1:19pm UTC](https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185/2 "2018-04-16T13:19:26Z")

</div>

You can't reference scripted fields from other scripted fields like that in Painless unfortunately.

---

<div class="post-metadata">

**Author:** ![didinyah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/didinyah/32/30859_2.png) [@didinyah](https://discuss.elastic.co/u/didinyah)\
**Post date:** [April 16, 2018, 1:26pm UTC](https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185/3 "2018-04-16T13:26:26Z")

</div>

Okay that's what I thought...

So I guess i'll have to find a workaround solution for this problem. Thanks.

---

<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 17, 2018, 1:29pm UTC](https://discuss.elastic.co/t/scripted-field-using-2-others-scripted-fields/128185/5 "2018-05-17T13:29:46Z")

</div>

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