# Show an Scripted Value in a Visualization

**URL:** <https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630>\
**Category:** Kibana\
**Created:** [February 8, 2021, 3:56pm UTC](https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630 "2021-02-08T15:56:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Montoya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan_montoya/32/83579_2.png) [@Juan\_Montoya](https://discuss.elastic.co/u/Juan_Montoya)\
**Post date:** [February 8, 2021, 3:56pm UTC](https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630/1 "2021-02-08T15:56:07Z")

</div>

Hi,

I'm creating a dashboard and now I need to show the unitary value of the products, this value must be dynamical along the time, the unitary value must be calculated adding all the prices and adding all the units to divide later, I had created a query in Elasticsearch that calculate the thing that I need. The problem is I don't know how to show the result in Kibana

```auto
    {
      "size": 0,
      "query": {
        "range": {
          "@timestamp": {
            "gte": "2021-01-01",
            "lte": "2021-02-08"
          }
        }
      },
      "aggs": {
        "Prducts": {
          "terms": {
            "field": "reg_nr.keyword",
            "size": 10
          },
          "aggs": {
            "total_unit": {
              "sum": {
                "field": "pesoneto"
              }
            },
            "total_flete": {
              "sum": {
                "field": "fletetot"
              }
            },
            "UnitaryValue": {
              "bucket_script": {
                "buckets_path": {
                  "unit": "total_unit",
                  "total": "total_flete"
                },
                "script": {
                  "source": "(params.total / params.unit)"
                }
              }
            }
          }
        }
      }
    }

```

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [February 9, 2021, 11:25am UTC](https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630/2 "2021-02-09T11:25:09Z")

</div>

Hello,  
Sadly the bucket script aggregation is not available in Kibana other visualizations:

> <https://github.com/elastic/kibana/issues/4707>
>
> Given the rhe new Bucket Script Aggregation, we can implement formulas from aggregated metric values (e.g. metric1 / metric2 \* 100)....

But you can use it in TSVB, where it's been renamed to Math aggregation.

---

<div class="post-metadata">

**Author:** ![Abbass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abbass/32/85817_2.png) [@Abbass](https://discuss.elastic.co/u/Abbass)\
**Post date:** [February 9, 2021, 2:32pm UTC](https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630/3 "2021-02-09T14:32:52Z")

</div>

@Juan_Montoya You can use [Vega](https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana) visualizations in Kibana.

It'll allow you to write and visualize your own query.

It is flexible enough to meet your requirements.

---

<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 9, 2021, 2:33pm UTC](https://discuss.elastic.co/t/show-an-scripted-value-in-a-visualization/263630/4 "2021-03-09T14:33:13Z")

</div>

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