Calculate global average over Date Histogram buckets

Hi,

not sure if this is clarified already somewhere, but at least I couldn't find it.

So, I have a vertical bar visualization in Kibana that shows sales figures for each week. On the Y-axis I have just a sum aggregation of a field called "amount" and on the X-axis I have a date histogram aggregation configured to show weekly buckets based on the field "time". In other words the visualization shows the weekly total sales.

Is it possible to add a global average weekly sales amount that is calculated over all of the weekly sales buckets? For example if my Elasticsearch data covers the past four weeks so that week 1 sales is 150 000, week 2 200 000, week 3 170 000 and week 4 120 000, the average would be 160 000. Just one value.

I know it is possible to use an average aggregation for the "amount" field that would show the average sales transaction during that week, but it's not what I'm looking for.

Thanks in advance!

Wouldn't the total average sales over a given timeframe give you the same figure? As in, if you were simply showing "Average Sales", with no splitting by time, and using a time range of 4 weeks, the final value should still be 160,000 even though you're not explicitly calculating one week at a time. The average of all the sales over the last 4 weeks is the same as the average of the last 4 weekly averages, no?

Thanks for your answer. I guess your approach works in general, but in my case I specifically need an average weekly figure.

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