# Canvas: compare count from two indices

**URL:** <https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [May 31, 2021, 7:10am UTC](https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458 "2021-05-31T07:10:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomr/32/48260_2.png) [@tomr](https://discuss.elastic.co/u/tomr)\
**Post date:** [May 31, 2021, 7:10am UTC](https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458/1 "2021-05-31T07:10:18Z")

</div>

I'm trying to compare two counts using Canvas.

My queries are a straight count of documents from one index:

```auto
SELECT COUNT(*) AS c1 FROM index1

```

And the count of a particular field value in another index:

```auto
SELECT COUNT(*) AS c2 FROM index2 WHERE field = value

```

I can't figure out the correct way to call the second `essql` query from with a `math` function (and I'm not really sure that's the right way to do it).

I tried following some other posts in the forum (like [this one](https://discuss.elastic.co/t/canvas-multiple-math-functions-essql/249302/3)), but I'm stuck. So, how can I use two `essql` queries to get a ratio?

---

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [May 31, 2021, 11:43am UTC](https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458/2 "2021-05-31T11:43:47Z")

</div>

Can you also specify which version of Kibana/ES are you running?  
If you saw that thread, it said you could assign variable in the canvas expression editor (check Wylie’s @wylie comment), also what do you see as an output once you use them as suggested?  
I might be able to help you out as I have spent a lot of time figuring out the right query for my dashboards

---

<div class="post-metadata">

**Author:** ![tomr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomr/32/48260_2.png) [@tomr](https://discuss.elastic.co/u/tomr)\
**Post date:** [May 31, 2021, 12:55pm UTC](https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458/3 "2021-05-31T12:55:41Z")

</div>

Thanks for the attention.

Kibana and ES are version 7.12.1

I didn't really fully understand those suggestions, but I'll have another try and post my results.

---

<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:** [June 28, 2021, 12:56pm UTC](https://discuss.elastic.co/t/canvas-compare-count-from-two-indices/274458/4 "2021-06-28T12:56:20Z")

</div>

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