# Visualize: Scripted field and median aggregation

**URL:** https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225
**Category:** Kibana
**Created:** [August 25, 2020, 6:41am UTC](https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225 "2020-08-25T06:41:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![boernd](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@boernd](https://discuss.elastic.co/u/boernd)
#### Post date: [August 25, 2020, 6:41am UTC](https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225/1 "2020-08-25T06:41:15Z")

</div>

Hi,

after upgrading Kibana to 7.8.1 (also tested with 7.9.0) from 7.5.2 some visualizations using the median aggregation on scripted fields seem broken as they do not display anything. I could reproduce this quite easily:

- Create a scripted field on a number field which in my case just reformats the ms to minutes
- Create a e.g. bar visualization and use a "Median" aggregation for the "Y-axis" on the scripted field. The visualization displays nothing.

The response shows null for the 50th percentile:

```auto
    {
      "took": 197,
      "timed_out": false,
      "_shards": {
        "total": 30,
        "successful": 30,
        "skipped": 15,
        "failed": 0
      },
      "hits": {
        "total": 3548722,
        "max_score": null,
        "hits": []
      },
      "aggregations": {
        "1": {
          "values": {
            "50.0": null
          }
        }
      }
    }

```

Interestingly the 50th percentile aggregation (which is basically the same right?) shows a result. Should I open a Github issue, I could not find an existing one? Just not sure if it is a Kibana or Elasticsearch issue.

Regards  
Bernd

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [August 25, 2020, 10:15pm UTC](https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225/2 "2020-08-25T22:15:26Z")

</div>

Hi, I could not find a related issue either. Please go ahead and file a bug.

Does the issue only happen when the number field is a scripted field? Does the same thing happen for other aggregation types with numeric scripted fields?

---

<div class="post-metadata">

### Author: ![boernd](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@boernd](https://discuss.elastic.co/u/boernd)
#### Post date: [August 26, 2020, 6:28am UTC](https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225/3 "2020-08-26T06:28:03Z")

</div>

> <https://github.com/elastic/kibana/issues/75946>
>
> Kibana version: 7.8.1
> Elasticsearch version: 7.8.1
> Server OS version: Official Elastic docker image
> Browser version: Firefox 79.0 (64-Bit)
> Browser OS version: Windows 10 Version 1809
> Original...

Tbh I did not test all aggregation types but Average and Percentile at least work.

---

<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: [September 23, 2020, 6:28am UTC](https://discuss.elastic.co/t/visualize-scripted-field-and-median-aggregation/246225/4 "2020-09-23T06:28:05Z")

</div>

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