# Calculate the moving standard deviation of count on a histogram aggregation

**URL:** <https://discuss.elastic.co/t/calculate-the-moving-standard-deviation-of-count-on-a-histogram-aggregation/61269>\
**Category:** Elasticsearch\
**Created:** [September 22, 2016, 2:36pm UTC](https://discuss.elastic.co/t/calculate-the-moving-standard-deviation-of-count-on-a-histogram-aggregation/61269 "2016-09-22T14:36:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucyy](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lucyy](https://discuss.elastic.co/u/lucyy)\
**Post date:** [September 22, 2016, 2:36pm UTC](https://discuss.elastic.co/t/calculate-the-moving-standard-deviation-of-count-on-a-histogram-aggregation/61269/1 "2016-09-22T14:36:09Z")

</div>

I want to calculate the moving average and standard deviation of daily count of twitter data. I know I can use the 'moving\_avg' in the pipeline aggregation for the moving average, but how to compute the moving standard deviation of the count?

Thank you for the help and here is my code:

"aggs": {  
"daily\_count": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "day"  
},  
"aggs": {  
"count": {  
"value\_count": {  
"field": "id\_str"  
}  
},  
"mvavg": {  
"moving\_avg": {  
"buckets\_path": "count",  
"window": 14,  
"model": "simple"  
}  
},  
"mvstd": {  
how to do this part......?  
}  
}  
}

---

<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 5, 2017, 10:18pm UTC](https://discuss.elastic.co/t/calculate-the-moving-standard-deviation-of-count-on-a-histogram-aggregation/61269/2 "2017-07-05T22:18:05Z")

</div>


