# Timelion split and divide not working well

**URL:** <https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [June 22, 2018, 2:02pm UTC](https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034 "2018-06-22T14:02:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent\_valdy](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@vincent\_valdy](https://discuss.elastic.co/u/vincent_valdy)\
**Post date:** [June 22, 2018, 2:02pm UTC](https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034/1 "2018-06-22T14:02:06Z")

</div>

let's consider the following data  
`POST /sales/forecast/ {"product":"banana","state":"unsure","price":10,	"@timestamp": "2018-06-20T10:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"banana","state":"confirmed","price":20,	"@timestamp": "2018-06-20T11:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"banana","state":"confirmed","price":40, "@timestamp": "2018-06-21T10:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"banana","state":"confirmed","price":30,	"@timestamp": "2018-06-21T11:00:00.000Z" }`

`POST /sales/forecast/ {"product":"orange","state":"confirmed","price":1, "@timestamp": "2018-06-20T12:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"orange","state":"unsure","price":2, "@timestamp": "2018-06-20T13:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"orange","state":"confirmed","price":4, "@timestamp": "2018-06-21T12:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"orange","state":"confirmed","price":3, "@timestamp": "2018-06-21T13:00:00.000Z" }`

`POST /sales/forecast/ {"product":"lemon","state":"unsure","price":3, "@timestamp": "2018-06-20T14:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"lemon","state":"unsure","price":5, "@timestamp": "2018-06-20T15:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"lemon","state":"unsure","price":7, "@timestamp": "2018-06-21T14:00:00.000Z" }`  
`POST /sales/forecast/ {"product":"lemon","state":"unsure","price":8, "@timestamp": "2018-06-21T15:00:00.000Z" }`

using timelion I want to know the precentage of banana I am sure to sell:  
`.es(q="+state=confirmed +product=banana",index=sales*,metric=sum:price).divide(.es(q="product=banana",index=sales*,metric=sum:price)),`  
same goes for lemon and orange  
let say I want to use "split" to get these graph:  
`.es(q="+state=confirmed",index=sales*,metric=sum:price,split=product.keyword:3).divide(.es(q="*",index=sales*,metric=sum:price, split=product.keyword:3)),`  
this timelion code answer : Unable to pairwise reduce seriesLists, number of series are not the same  
if I change the split factor 3 to 2 for example I get : Matching series could not be found for "orange" in ["banana","lemon"].

1. is this a bug (or lack of functionality)
2. if yes, could it be fixed (or is it by design)
3. is there a workaround that would work if a new products arrive without me changing my dashboard each time a new products arrives

---

<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:** [June 26, 2018, 12:39am UTC](https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034/2 "2018-06-26T00:39:35Z")

</div>

Does `split` return the same keys for each query? Run each `es` statement separately and see what split is returning. If the terms are not the same, then there is no way to divide the series because timelion does not know how to pair up the split results.

---

<div class="post-metadata">

**Author:** ![vincent\_valdy](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@vincent\_valdy](https://discuss.elastic.co/u/vincent_valdy)\
**Post date:** [June 28, 2018, 9:11am UTC](https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034/3 "2018-06-28T09:11:34Z")

</div>

the problem is that the split does not return the same terms depending of the timerange.......  
with this data the returned keys are never the same but adding this data:  
`POST /sales/forecast/ {"product":"lemon","state":"confirmed","price":8, "@timestamp": "2018-06-21T15:00:00.000Z" }`

will make both parts of the divide return the same lists (depending of the timerange)

---

<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:** [July 26, 2018, 9:11am UTC](https://discuss.elastic.co/t/timelion-split-and-divide-not-working-well/137034/4 "2018-07-26T09:11:36Z")

</div>

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