# Count max consecutive values

**URL:** <https://discuss.elastic.co/t/count-max-consecutive-values/253565>\
**Category:** Elasticsearch\
**Created:** [October 28, 2020, 1:33pm UTC](https://discuss.elastic.co/t/count-max-consecutive-values/253565 "2020-10-28T13:33:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yevhen\_Baidiuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yevhen_baidiuk/32/57956_2.png) [@Yevhen\_Baidiuk](https://discuss.elastic.co/u/Yevhen_Baidiuk)\
**Post date:** [October 28, 2020, 1:33pm UTC](https://discuss.elastic.co/t/count-max-consecutive-values/253565/1 "2020-10-28T13:33:19Z")

</div>

Hello, I try to get values with specific logic.

For Example, we get 2 Entity from 4 days period.

Name Date Val  
B 01 1 (1)  
A 01 **1**  
A 02 0  
A 03 **1**  
A 04 **1** (2)

In response, I want to count max\_consecutive days for Name where val=1.  
Not interrupted by 0

So B=1, A=2

Thanks

---

<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:** [November 25, 2020, 1:33pm UTC](https://discuss.elastic.co/t/count-max-consecutive-values/253565/2 "2020-11-25T13:33:34Z")

</div>

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