# Maps: Doing simple math on a region Aggregation

**URL:** <https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990>\
**Category:** Kibana\
**Created:** [July 30, 2019, 8:47pm UTC](https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990 "2019-07-30T20:47:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![avocado](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@avocado](https://discuss.elastic.co/u/avocado)\
**Post date:** [July 30, 2019, 8:47pm UTC](https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990/1 "2019-07-30T20:47:16Z")

</div>

I have an index (index1) with that contains documents with a geo spatial boundary field and an associated area field. I have a second index (index2) that includes documents with a simple geopoint field.

I would like use the Maps app to do a simple calculation:  
I want to do a count aggregation of the documents in index2 for each region in index1, then I would like the color scale for the regions on the map to be displayed as the ratio of Count/Region Area. Is there any good way to do this?

Things I have already tried:

1. Scripted fields don't work because can only apply on a single index
2. I tried to do this in a Vega visualization, with a bucket aggregation query but I am limited to only showing 10,000 region boundaries and I have more than 10,000

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)\
**Post date:** [July 30, 2019, 9:13pm UTC](https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990/2 "2019-07-30T21:13:05Z")

</div>

Hello,

Dynamic color ranges in the Maps App aren't possible yet. There is however [a PR in progress](https://github.com/elastic/kibana/pull/41603) along with some relevant linked issues.

Regards,  
Aaron

---

<div class="post-metadata">

**Author:** ![avocado](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@avocado](https://discuss.elastic.co/u/avocado)\
**Post date:** [July 30, 2019, 10:14pm UTC](https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990/3 "2019-07-30T22:14:44Z")

</div>

Thanks Aaron, this actually isn't really what I'm looking for. The part that is hard is to do basic math in the aggregation query within a Kibana Map or other type of Visualization

For example a Count aggregation where the result is divided by a constant can easily be done that way, but then I have no way to display the result unless I build a custom Vega visualization

In the case described above a Vega map would be a fine solution, however, since the query is limited to 10000 results I can't do it easily. Maps would be a great solution, but I don't think there is any way to do this?

---

<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 27, 2019, 10:14pm UTC](https://discuss.elastic.co/t/maps-doing-simple-math-on-a-region-aggregation/192990/4 "2019-08-27T22:14:50Z")

</div>

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