# Scripted field to calculate

**URL:** <https://discuss.elastic.co/t/scripted-field-to-calculate/264754>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [February 18, 2021, 6:43pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate/264754 "2021-02-18T18:43:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ITchandj](https://avatars.discourse-cdn.com/v4/letter/i/f19dbf/32.png) [@ITchandj](https://discuss.elastic.co/u/ITchandj)\
**Post date:** [February 18, 2021, 6:43pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate/264754/1 "2021-02-18T18:43:06Z")

</div>

Hello community!!

please how can i write a Scripted fields that calculed in follow operation. thanks for your advice

Lifetime = ProcStartTimeRelativeMs + ";" + ProcLifetimeMs + ";" + TotalBootDurationMs + ";" + ProcName + ";" + SessionID

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [February 18, 2021, 9:56pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate/264754/2 "2021-02-18T21:56:35Z")

</div>

You'll want to use a Painless script something like this:

```auto
doc['ProcStartTimeRelativeMs'].value + ";" + doc['ProcLifetimeMs'].value + ";" + doc['TotalBootDurationMs'].value + ";" + doc['ProcName'].value + ";" + doc['SessionID'].value

```

---

<div class="post-metadata">

**Author:** ![ITchandj](https://avatars.discourse-cdn.com/v4/letter/i/f19dbf/32.png) [@ITchandj](https://discuss.elastic.co/u/ITchandj)\
**Post date:** [February 21, 2021, 9:25am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate/264754/3 "2021-02-21T09:25:21Z")

</div>

thank you for answer.  
i wrote it like this

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

But i get this error , when i use the field name in kibana. please do you have any idea about the error.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/e/4e8c46a8fc0ec8ee2cf9619ece74f383258460f1.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/7/7/777e517effdfe831c76ea5f81e8dc2fd6833a6ac.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 21, 2021, 9:25am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate/264754/4 "2021-03-21T09:25:30Z")

</div>

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