# How to plot a graph using data from two filters?

**URL:** <https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186>\
**Category:** Kibana\
**Created:** [November 3, 2020, 9:33pm UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186 "2020-11-03T21:33:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![I\_Hathout](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/i_hathout/32/76915_2.png) [@I\_Hathout](https://discuss.elastic.co/u/I_Hathout)\
**Post date:** [November 3, 2020, 9:33pm UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186/1 "2020-11-03T21:33:21Z")

</div>

I've two filters each of which gets data from a database query.

 ![trf_faliure_records](https://us1.discourse-cdn.com/elastic/original/3X/a/f/afd558fc00f17dad70d74484c78b17b6337e5b56.png) ![trf_records](https://us1.discourse-cdn.com/elastic/original/3X/9/2/927e3489a5859c7731a4442fc5c2b43555ae657e.png)

I wanna have a single visualization vertical bar which has data histograms monthly on X axis and for the Y-axis, I need to (count transfer failures from first filter)/(count all month transfers from 2nd filter).

Example suppose I have 40 total transfers in may 'getting from 2nd filter' and 10 transfer failures getting from 1st filter so the x axis should be May 2020 and y axis should be a point in (10/40 =.025)

---

<div class="post-metadata">

**Author:** ![Iker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iker/32/91708_2.png) [@Iker](https://discuss.elastic.co/u/Iker)\
**Post date:** [November 3, 2020, 10:19pm UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186/2 "2020-11-03T22:19:24Z")

</div>

I think there are two ways to achieve that, the first will be creating a new Kibana index that groups the two index, so you could use a typical bar visualization and filter the data; the second is using a Time Series Visual Builder visualization and using the "Filter Ratio" aggregation to get the results that you expect.

Hope it Helps

---

<div class="post-metadata">

**Author:** ![I\_Hathout](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/i_hathout/32/76915_2.png) [@I\_Hathout](https://discuss.elastic.co/u/I_Hathout)\
**Post date:** [November 4, 2020, 11:13am UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186/3 "2020-11-04T11:13:37Z")

</div>

Thanks. I decided to go with the first option. I did add a filter to combine both filters, but I still can't find a way to count the faliure data monthly / divide the number on all the transfers for that month and visualize the results on the Y-axis.!

 ![trf_records](https://us1.discourse-cdn.com/elastic/original/3X/5/5/552b65e1559f2afb1822ea90cbfe0b3f3349c0b4.png)

---

<div class="post-metadata">

**Author:** ![Iker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iker/32/91708_2.png) [@Iker](https://discuss.elastic.co/u/Iker)\
**Post date:** [November 5, 2020, 5:26am UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186/4 "2020-11-05T05:26:25Z")

</div>

My bad, i misunderstood the first statement, definitely you should go with the TSVB on the new index, you could use the filter ratio or multiple metrics and a math metric. Example:

 ![image_2020-11-05_002538](https://us1.discourse-cdn.com/elastic/original/3X/4/3/43fa3b8fe8670a30b104d193a4426238c5106843.png)

So, you use sum metrics instead of max.

---

<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:** [December 3, 2020, 5:26am UTC](https://discuss.elastic.co/t/how-to-plot-a-graph-using-data-from-two-filters/254186/5 "2020-12-03T05:26:27Z")

</div>

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