# Calculate and visualize from two indices

**URL:** <https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690>\
**Category:** Kibana\
**Created:** [July 12, 2018, 7:36am UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690 "2018-07-12T07:36:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![someOne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/someone/32/32154_2.png) [@someOne](https://discuss.elastic.co/u/someOne)\
**Post date:** [July 12, 2018, 7:36am UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/1 "2018-07-12T07:36:59Z")

</div>

In my use case  
One index is sales history like:

```
BranchID ItemID Prices Sale_date
 PA1100 O18740 75 4/11/2018
 PA6840 P25400 100 4/11/2018
   .. .. .. ..

```

And the other is base line (documentation) like:

```
BranchID Region County Location Goal
 PA1100 North City A Street I,45 200000
 PA2001 East City B Street J,87 155000
 PA2045 East City C Street K,22 180000
   .. .. .. .. ..

```

Both indices have more than ten thousands of documents.  
So,How can I create a percentage visualizer by using sum of prices in sales history divided by sum of goal in base line.

Elastic Version : 6.2.4  
Thanks for any help in advance.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [July 12, 2018, 1:51pm UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/2 "2018-07-12T13:51:45Z")

</div>

[Canvas](https://canvas.elastic.co/) is being created to solve problems like these. It allows you to build visualizations from SQL statements that allow you to perform joins. I would recommend you try it out for this problem set.

If canvas does not work for you then, only timelion and visual builder offer support for multiple indices. You could create an expression that looks something like this in timelion `.es(index="sales_history",timefield="yourTimefield",metric=sum:price).divide(.es(index="base_line",timefield="yourTimefield",metric=sum:goal))`

---

<div class="post-metadata">

**Author:** ![someOne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/someone/32/32154_2.png) [@someOne](https://discuss.elastic.co/u/someOne)\
**Post date:** [July 13, 2018, 2:39am UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/3 "2018-07-13T02:39:52Z")

</div>

> [@Nathan\_Reese](#):
>
> If canvas does not work for you then, only timelion and visual builder offer support for multiple indices. You could create an expression that looks something like this in timelion `.es(index="sales_history",timefield="yourTimefield",metric=sum:price).divide(.es(index="base_line",timefield="yourTimefield",metric=sum:goal))`

In base\_line index have no timefield that cause no result show on timelion.  
I will learn about canvas from your suggestion.

---

<div class="post-metadata">

**Author:** ![someOne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/someone/32/32154_2.png) [@someOne](https://discuss.elastic.co/u/someOne)\
**Post date:** [July 17, 2018, 3:17am UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/4 "2018-07-17T03:17:39Z")

</div>

@Nathan_Reese  
Canvas doesn't work for me because It is not a dynamic visualizer.  
any ideas to solve this problem.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [July 17, 2018, 2:53pm UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/5 "2018-07-17T14:53:58Z")

</div>

What do you mean by "dynamic visualize"? What problems are you having with canvas?

---

<div class="post-metadata">

**Author:** ![someOne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/someone/32/32154_2.png) [@someOne](https://discuss.elastic.co/u/someOne)\
**Post date:** [July 18, 2018, 2:03am UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/6 "2018-07-18T02:03:01Z")

</div>

I mean chart on visualize can filter by click on themselves.  
How can I link or combine the indices. That make me use data from two indices in one visualize.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [July 18, 2018, 2:20pm UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/7 "2018-07-18T14:20:37Z")

</div>

I would recommend opening an enhancement issue for you feature request

---

<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 15, 2018, 2:20pm UTC](https://discuss.elastic.co/t/calculate-and-visualize-from-two-indices/139690/8 "2018-08-15T14:20:41Z")

</div>

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