# Scripted Field for sum of max value!

**URL:** <https://discuss.elastic.co/t/scripted-field-for-sum-of-max-value/35804>\
**Category:** Kibana\
**Created:** [November 28, 2015, 2:42pm UTC](https://discuss.elastic.co/t/scripted-field-for-sum-of-max-value/35804 "2015-11-28T14:42:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gugansankar](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@gugansankar](https://discuss.elastic.co/u/gugansankar)\
**Post date:** [November 28, 2015, 2:42pm UTC](https://discuss.elastic.co/t/scripted-field-for-sum-of-max-value/35804/1 "2015-11-28T14:42:28Z")

</div>

I would like to write the script that need to show "Sum of Max value" .

For example,

![](https://us1.discourse-cdn.com/elastic/original/2X/e/e73feac454198542b25664d7b5a85e848e386167.png)

Here, you can see same IP has opened two session and view the page.The value is accumulated [incremental] one. So I have to take max value of each session and sum the output.

Hence, I will get an exact and total amount used per IP.

How can I implement this in scripted field in kibana4

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 28, 2015, 11:44pm UTC](https://discuss.elastic.co/t/scripted-field-for-sum-of-max-value/35804/2 "2015-11-28T23:44:18Z")

</div>

Not sure you can at the moment.  
Pipeline aggs should help once they have been implemented.

---

<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:** [July 6, 2017, 2:08pm UTC](https://discuss.elastic.co/t/scripted-field-for-sum-of-max-value/35804/3 "2017-07-06T14:08:01Z")

</div>


