# Median Forumla Question

**URL:** <https://discuss.elastic.co/t/median-forumla-question/329238>\
**Category:** Kibana\
**Created:** [April 3, 2023, 4:51pm UTC](https://discuss.elastic.co/t/median-forumla-question/329238 "2023-04-03T16:51:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Boyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshua_boyd/32/118075_2.png) [@Joshua\_Boyd](https://discuss.elastic.co/u/Joshua_Boyd)\
**Post date:** [April 3, 2023, 4:51pm UTC](https://discuss.elastic.co/t/median-forumla-question/329238/1 "2023-04-03T16:51:40Z")

</div>

Hello, wondering if anyone could give advice on the following:

i have a table of incidents, with column of account name and the incident id

incident1, account1  
incident2, account1  
incident3, account2  
....

I want to do a count of incidents by account and then return the median of those values.

(total incidents, account1), (total incidents, account2), (total incidents, account 3)

if the values looked like

(4,1,7)

I'd want to return the median of 4.

Is there anyway to write a formula like this?

I was calculating the average per client, but there's such a discrepancy with my larger clients, i need to switch to median

What i was using to calculate the average:  
unique\_count(incident.investigationId, kql='not incident.category : "job" ') / unique\_count(incident.account)

---

<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 1, 2023, 4:52pm UTC](https://discuss.elastic.co/t/median-forumla-question/329238/2 "2023-05-01T16:52:35Z")

</div>

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