Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Moving Average

Hello ..
This select returns the cumulative sum.
LOAD Produto,Vendas, NumSum (PEEK ('CSum'),Vendas) AS CSum;
LOAD *INLINE [
Produto, Vendas
A, 10
B,30
C,10
D,20
E,10
F,20
]
;
ProdutoSum (Vendas)SUM(CSum)
100350,00
A1010,00
B3040,00
C1050,00
D2070,00
E1080,00
F20100,00
I need a moving average of these values ​​and not the sum.
ProdutoSum (Vendas)SUM(CSum) Avg
100350,00
A1010,0010,0
B3040,0020,0
C1050,0016,7
D2070,0017,5
E1080,0016,0
F20100,0016,7
1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try dividing by rowno():

numsum(Peek('CSum'),Vendas)/RowNo() as RAvg

Regards,

Stefan

View solution in original post

2 Replies
swuehl
MVP
MVP

Try dividing by rowno():

numsum(Peek('CSum'),Vendas)/RowNo() as RAvg

Regards,

Stefan

Anonymous
Not applicable
Author

Beauty, solved the problem, thanks.