Calculating variance using kibana

Want to calculate variance for a time series data of multiple restaurants with number of customers visiting every day.

date          name       numCustomers
1-Sep-2016  restaurant1 40
2-Sep-2016  restaurant1 30
3-Sep-2016  restaurant1 35
--------------------------
1-Sep-2016  restaurant2 20
2-Sep-2016  restaurant2 24
--------------------------
1-Sep-2016  restaurant3 50
3-Sep-2016  restaurant3 45

For a each week, want to find variance in number of customers visiting each restaurant.

i.e. want to first bucketize the data per week. Then sum numCustomers for each restaurant and find variance on calculated sum. For above example need to find variance for [ restaurant1(40+30+35), restaurant2(20+24), restaurant3(50+45) ]

Looked at extended stats aggregation but not sure how this can be utilized here.

You could use Pipeline Aggregations for this computation.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html

This has to be done in Elasticsearch, though, and support for Pipeline Aggregations in Kibana is still forthcoming.