# Taking average of a numeric field and customise it

**URL:** <https://discuss.elastic.co/t/taking-average-of-a-numeric-field-and-customise-it/352179>\
**Category:** Kibana\
**Created:** [January 31, 2024, 11:12am UTC](https://discuss.elastic.co/t/taking-average-of-a-numeric-field-and-customise-it/352179 "2024-01-31T11:12:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharmavipul92](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sharmavipul92](https://discuss.elastic.co/u/sharmavipul92)\
**Post date:** [January 31, 2024, 11:12am UTC](https://discuss.elastic.co/t/taking-average-of-a-numeric-field-and-customise-it/352179/1 "2024-01-31T11:12:34Z")

</div>

Hi

I have a duration field of type number having duration in milliseconds. I want to take the average of it, and show it in kibana dashboard metrics as dd:hh:mm:ss format, or basically run a script over the average value to customise the format.

I have tried using scripted field to convert it to a human readable format. though it works perfectly for me, but then when i search for the scripted field in kibana dashboard, it gives me query\_shard\_exception.  
so first question, can i make this scripted field as non-searchable? how?

second question, can i do the same thing using runtime field? where i can specify the format as duration and output format as "human-readable"?

The end goal is to show average duration in a human readable format in kibana metrics, and the field should be either searchable or doesn't show up in the search at all.

I am using 7.17 version.

---

<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 2, 2024, 4:36pm UTC](https://discuss.elastic.co/t/taking-average-of-a-numeric-field-and-customise-it/352179/2 "2024-02-02T16:36:50Z")

</div>

Yes you can do this for runtime fields when you're editing/adding the field:

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

What is the shard error you're getting? Is it possible you're forgetting to check if the underlying field actually exists in the document?

---

<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 1, 2024, 4:37pm UTC](https://discuss.elastic.co/t/taking-average-of-a-numeric-field-and-customise-it/352179/3 "2024-03-01T16:37:09Z")

</div>

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