I have these records for 1961-2016 period. I have plotted the data corresponding to the 7th month for the entire period, together with the average aggregation for the same period.
Query:
.es(q="month:7", index=1961-2016*, timefield="@timestamp", metric='avg:T').label("Values each year from 1961 to 2016"), .es(q="month:7", index=1961-2016*, timefield="@timestamp", metric='avg:T').aggregate('avg').label("Average 1961-2016")
Plot:
But what I would actually want to do is to compare the evolution through the entire period with the average of a smaller timerange - 1961 TO 1990
This is what I tried (query):
.es(q="month:7", index=1961-2016*, timefield="@timestamp", metric='avg:T').label("Values each year from 1961 to 2016"), .es(q="month:7 AND year:[1961 TO 1990]", index=1961-2016*, timefield="@timestamp", metric='avg:T').aggregate('avg').label("Average 1961-1990")
And this is what I'm obtaining (plot):
Changing the query from q="month:7 AND year:[1961 TO 1990]" to q="month:7 AND year:[1961 TO 2016]" displays correct. So the problem would be that the average aggregation is calculate by dividing it to the number of years in the whole timespan, not to the number of years from the query I added.
Is there any way of accomplishing what I want? Thank you,

