Question regarding moving average


I am trying to display the simple moving average of my data over a period of 3. However, the moving average ignores my lastest entry of data. It still calculates the moving average of 3 windows, its just that my last line of data is always ignored.

I have attached some images below, and hopefully it would be able to express the problem that I am facing.

When I set the window to 3, the moving average is displayed as 23.67. This means that it is calculated using my values 18+37+16 = 71, and 71/3 = 23.67. From my understanding, the calculation should be 31+16+37 = 84, and 84/3 = 28. This means that the moving average function is not taking in my latest value for calculation.

This is another example, where I set my window to 1 and it displayed 16 instead of 31.

I am unsure of what went wrong. Any thoughts?

Thank you!


Quick update: After exploring the query inspector, I concluded that the data streaming in from elastic search is correct, not so sure whats the issue. Anyone able to help?

HI @cytan can you share your sql query to generate the moving average? Thanks.