# Take/calculate value from dashboard

**URL:** <https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093>\
**Category:** Kibana\
**Created:** [December 18, 2020, 11:56am UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093 "2020-12-18T11:56:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blukit](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@blukit](https://discuss.elastic.co/u/blukit)\
**Post date:** [December 18, 2020, 11:56am UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/1 "2020-12-18T11:56:12Z")

</div>

Hi guys...

Is it possible to calculate value directly from a dashboard?  
The underlying logic of existing metrics kinda complex, so i think it would be more simple if I could take the output for other calculation.

![percent](https://us1.discourse-cdn.com/elastic/original/3X/f/f/fffe86053b580abc5c0e213ba456d6c0720abc0e.png)

example: (purchase-cashout)/purchase

ps: using version 6.8

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [December 18, 2020, 3:44pm UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/2 "2020-12-18T15:44:55Z")

</div>

> Is it possible to calculate value directly from a dashboard?

The short answer is "no" -- you can't do this directly from a dashboard. _However_, you can achieve this using a TSVB visualization (which can then be embedded in a dashboard).

What you're looking to do is called a [bucket script aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-aggregations-pipeline-bucket-script-aggregation.html), which is [not yet supported in our standard agg-based visualizations](https://github.com/elastic/kibana/issues/4707), but [can be done using TSVB as shown here](https://github.com/elastic/kibana/issues/4707#issuecomment-325997105). Another more detailed example can be found in this thread:

> [@Weighted Average in a DataTable of Kibana](https://discuss.elastic.co/t/weighted-average-in-a-datatable-of-kibana/185909/2):
>
> Hi Henrique, I think solving your problem will be a two-step process. You'll need to create a per-document field for cost \* volume, e.g. a field called volumeCost. You could create this field two ways, either by [reindexing your data](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html#docs-reindex) and adding the field with a Painless script, or by creating a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) that calculates this value on the fly. The first option is a little more performant when querying your data but the second option might be easier. I think you can create a Timeseries v…

---

<div class="post-metadata">

**Author:** ![blukit](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@blukit](https://discuss.elastic.co/u/blukit)\
**Post date:** [December 21, 2020, 8:07am UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/3 "2020-12-21T08:07:24Z")

</div>

Thanks for the feedback & link.

I've tried 'bucket script' & 'math' aggregation in visual builder, but sometimes it didn't shows data correctly in dashboard (0 result) when i know for sure data exist. But when I edit it, it shows correctly. Any clue to solve this?

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [December 29, 2020, 2:56pm UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/4 "2020-12-29T14:56:37Z")

</div>

> [@blukit](#):
>
> sometimes it didn't shows data correctly in dashboard (0 result) when i know for sure data exist. But when I edit it, it shows correctly

What do you mean exactly by "when I edit it"? It works after editing the dashboard, or editing the TSVB visualization again?

---

<div class="post-metadata">

**Author:** ![blukit](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@blukit](https://discuss.elastic.co/u/blukit)\
**Post date:** [January 8, 2021, 5:07am UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/5 "2021-01-08T05:07:21Z")

</div>

sometimes during edit/save, other times when I move forward/backward with the time picker

i'm using visual builder:  
value count --\> cumulative sum --\> bucket script

---

<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:** [February 5, 2021, 5:07am UTC](https://discuss.elastic.co/t/take-calculate-value-from-dashboard/259093/6 "2021-02-05T05:07:28Z")

</div>

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