Graph with percent change between bucket

I have an index with Elasticsearch which contains (inter alia) date and weight fields. I create a date histogram with bucket size year and I would like to calculate (in meta-language) sth like: sum(weight[year])/sum(weight[year-1]).

I can create an aggregation sum(weight), but how to calculate a faction of bucket-to-bucket values?
There is Serial Differencing Aggregation or Derivative, but it just subtracts the values between buckets and I need to divide them.

I will appreciate some clues how to achieve it.

Ok, I have managed to solve it using TImelion with the following query:
.es(index=myindex,timefield=year_date,metric=sum:weight).divide(.es(index=myindex,timefield=year_date,metric=sum:weight,offset=-1y)).multiply(100).subtract(100).bars()

1 Like

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