# Show visualization of calculation between two field

**URL:** <https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535>\
**Category:** Kibana\
**Created:** [July 18, 2018, 11:54am UTC](https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535 "2018-07-18T11:54:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drav3nmc](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@Drav3nmc](https://discuss.elastic.co/u/Drav3nmc)\
**Post date:** [July 18, 2018, 11:54am UTC](https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535/1 "2018-07-18T11:54:23Z")

</div>

Hi All

I am collecting vsphere stats via metricbeat and sending them to my elastic install.

What I would like to be able to show is the %age of cpu used and memory used.  
Below is a log that shows the total cpu and used cpu and total memory and used memory, is it possible to do the calculation on these two fields to get the %age used and then show this as a visualization for a new dashboard i am building for office

 ![vspherehost](https://us1.discourse-cdn.com/elastic/original/3X/c/8/c8983426e550a3e762eb4599fa84466f5ce493c5.JPG)

Thanks in advance  
Mar

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [July 18, 2018, 6:11pm UTC](https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535/2 "2018-07-18T18:11:39Z")

</div>

Yes, you can do this by creating a scripted field in **Management \> Index Patterns \> Scripted fields \> Add scripted field** : [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

Name the field whatever you'd like. The field should be `number` type and `Percent` format. The script itself should look something like this:

```auto
(doc['vsphere.host.cpu.used.mhz'].value + 0.0) / doc['vsphere.host.cpu.total.mhz'].value

```

Save the field and repeat the process for calculating memory. Then you can use the new scripted fields in visualizations.

---

<div class="post-metadata">

**Author:** ![Drav3nmc](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@Drav3nmc](https://discuss.elastic.co/u/Drav3nmc)\
**Post date:** [July 19, 2018, 10:00am UTC](https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535/3 "2018-07-19T10:00:32Z")

</div>

Jen-huang Thank you very much for your reply.  
I have now got exactly what I was after, such a brilliant product and community

Mark

---

<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:** [August 16, 2018, 10:00am UTC](https://discuss.elastic.co/t/show-visualization-of-calculation-between-two-field/140535/4 "2018-08-16T10:00:39Z")

</div>

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