Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
bernarducs
Contributor
Contributor

How to script that cumsum?

Pessoal é o seguinte:

I got a data series month to month.  There, I have the total of jobs in every december and its balance (could be a positive or negative value) in the other months.

Goal: do a 12 month cumulative sum starting from December of year X to next November X+1. CumSum from December X+1 to November X+2 and so on...

Like the pic above.

tabela.png

How can I solve by scripting?

Labels (5)
2 Replies
Gysbert_Wassenaar

something like this:

 

tmp:
LOAD ano_mes, sum(valores) as sumValores FROM ...source...  GROUP BY ano_mes;

 

Result:
LOAD
    ano_mes,
    If(Right(ano_mes,2)=12, sumValores, rangesum(sumValores, peek(cumsumValores)) as cumsumValores
RESIDENT
    tmp
ORDER BY
   ano_mes
   ;

DROP TABLE tmp;

 

 


talk is cheap, supply exceeds demand
Brett_Bleess
Former Employee
Former Employee

Here is a Design Blog post to check out too:

https://community.qlik.com/t5/Qlik-Design-Blog/The-As-Of-Table/ba-p/1466130

Here is the base URL for this area from which you can search further:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Here is another site from one of our MVPs that may have some stuff too:

https://qlikviewcookbook.com/

If the other post did work for you, be sure to return to your thread and use the Accept as Solution button on that post to give them credit for the help and let other Members know that worked for you.  

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.