# Relation between two fields

**URL:** <https://discuss.elastic.co/t/relation-between-two-fields/36132>\
**Category:** Kibana\
**Created:** [December 2, 2015, 7:54am UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132 "2015-12-02T07:54:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henil\_shah](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@henil\_shah](https://discuss.elastic.co/u/henil_shah)\
**Post date:** [December 2, 2015, 7:54am UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132/1 "2015-12-02T07:54:02Z")

</div>

I have a health data where the fields are Population and Infected. Now for example the population of California is 38,802,500 and total infected are 50,000. Now I want to show how many are infected per 100,000 population? How can I do this in Kibana?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 2, 2015, 10:58am UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132/2 "2015-12-02T10:58:25Z")

</div>

You can use a script field for this.

[https://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-request-script-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-request-script-fields.html)

> **[Kibana 4 Beta 3: Now More Filtery
	  	 | Elastic](https://www.elastic.co/blog/kibana-4-beta-3-now-more-filtery)**
>
> Kibana 4 Beta 3 is out! Along with the usual smattering of small fixes come a few knockout headliners. Once again, we offer you the choice to dive right in by grabbing it here: download Kibana 4 Beta ...

---

<div class="post-metadata">

**Author:** ![henil\_shah](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@henil\_shah](https://discuss.elastic.co/u/henil_shah)\
**Post date:** [December 3, 2015, 5:48am UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132/3 "2015-12-03T05:48:02Z")

</div>

Hi Magnus,

I tried using script but its not working. Can you please write a script for it as it is urgent for me. I simply want that the population is 38 million and total affected are 90k so how many will get affected when the population is 100k. To simplify mathematical equation it is like

(100,000 \* Affected) / Total Population. I have two fields name Affected and Population.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 3, 2015, 6:46am UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132/4 "2015-12-03T06:46:34Z")

</div>

> I tried using script but its not working.

If you describe what you've done it'll be easier to point out what you're doing wrong. Translating the expression into Lucene's expression language is trivial so I can only assume it's something else you're having issues with.

> Can you please write a script for it as it is urgent for me.

When you have an urgent problem, try to anticipate what people are going to need to be able to help you. For example, "it's not working" will almost certainly result in people having to ask for more details, adding time for you.

---

<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 6, 2017, 2:07pm UTC](https://discuss.elastic.co/t/relation-between-two-fields/36132/5 "2017-07-06T14:07:33Z")

</div>

Closed on July 6, 2017, 2:07pm UTC


