# Formula to show percentage on gauge showing wrong values

**URL:** https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283
**Category:** Kibana
**Tags:** painless
**Created:** [June 3, 2022, 5:14am UTC](https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283 "2022-06-03T05:14:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![akshay\_bhardwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshay_bhardwaj/32/106428_2.png) [@akshay\_bhardwaj](https://discuss.elastic.co/u/akshay_bhardwaj)
#### Post date: [June 3, 2022, 5:14am UTC](https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283/1 "2022-06-03T05:14:12Z")

</div>

Formula to show percentage or division on gauge showing wrong values

I have used below advanced json formula but its showing zero.  
Please help and let me know the correct method to find percentage .

 ![Screenshot from 2022-06-03 10-43-46](https://us1.discourse-cdn.com/elastic/original/3X/1/4/14d9ef6c81e566b5081322d2f10461632af55180.png)

I need (sum of punctuality /count)\*100

```auto
{
  "script": {
    "inline": "doc['punctuality'].value/100",
    "lang": "painless" 
  }
}

```

---

<div class="post-metadata">

### Author: ![akshay\_bhardwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshay_bhardwaj/32/106428_2.png) [@akshay\_bhardwaj](https://discuss.elastic.co/u/akshay_bhardwaj)
#### Post date: [June 3, 2022, 1:45pm UTC](https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283/2 "2022-06-03T13:45:05Z")

</div>

Any solution?

---

<div class="post-metadata">

### Author: ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)
#### Post date: [June 3, 2022, 3:01pm UTC](https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283/3 "2022-06-03T15:01:43Z")

</div>

That is a scripted field, not a formula. The main difference is that with scripted/runtime fields you operate at each document level, while in formula it works at the aggregation level.

If you're looking to create a Gauge chart for a ratio ( A / B ) then you need to operate on a aggregation level. You might look into TSVB for that.

---

<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: [July 1, 2022, 3:01pm UTC](https://discuss.elastic.co/t/formula-to-show-percentage-on-gauge-showing-wrong-values/306283/4 "2022-07-01T15:01:47Z")

</div>

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