# Group in time series and filter by number of elements

**URL:** https://discuss.elastic.co/t/group-in-time-series-and-filter-by-number-of-elements/180945
**Category:** Kibana
**Created:** [May 14, 2019, 7:48am UTC](https://discuss.elastic.co/t/group-in-time-series-and-filter-by-number-of-elements/180945 "2019-05-14T07:48:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alesanchez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alesanchez/32/60189_2.png) [@alesanchez](https://discuss.elastic.co/u/alesanchez)
#### Post date: [May 14, 2019, 7:48am UTC](https://discuss.elastic.co/t/group-in-time-series-and-filter-by-number-of-elements/180945/1 "2019-05-14T07:48:16Z")

</div>

Hi everyone,  
let me explain what I have and what I want to achieve.

I have data about bank transfers. I want to do a time serie representing the average number of users that have made more than 2 transfers of a specific type. I have an index pattern containing all the transfers. Each transfer as an userId and a type.

What I want to do is filter the transfers by type and then group by userId. Then filter and retain only those groups which 2 o more transfers and lastly divide the number of groups by the total number of users registered.

I have another index pattern for the users only and another with the users and transfers.

I tried to achieve this using TSVB and Timelion and in both cases I can filter the transfers by type and group by userId but not filter the groups and compute the ratio.

Thank you very much for your time.

---

<div class="post-metadata">

### Author: ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)
#### Post date: [May 14, 2019, 8:18pm UTC](https://discuss.elastic.co/t/group-in-time-series-and-filter-by-number-of-elements/180945/2 "2019-05-14T20:18:13Z")

</div>

@alesanchez

computing the ratio you can do in Timelion by using the `.divide()` function. Basically, define the first series (with the breakdown, which is the numerator), and then divide by the other (which is all the transfers, the divisor).

Some examples of how it is used you can see here:  
[https://www.elastic.co/guide/en/kibana/current/timelion-math.html](https://www.elastic.co/guide/en/kibana/current/timelion-math.html)

> **[Getting Started with Time Series Analysis in Kibana](https://www.elastic.co/blog/timelion-tutorial-from-zero-to-hero)**
>
> A tutorial for timelion - the time series composer in Kibana - explaining everything you need to start working with timelion.

---

<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 11, 2019, 8:18pm UTC](https://discuss.elastic.co/t/group-in-time-series-and-filter-by-number-of-elements/180945/3 "2019-06-11T20:18:16Z")

</div>

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