Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to get a rolling value for each client. My data is set up as follows:
Table1:
Load *
Inline [
Client, Month, Value
AAA, 1, 300
AAA, 2, 550
AAA, 3, 600
BBB, 1, 250
BBB, 2, 475
];
I am trying to calculate the total value up to and including the current month for each client in the load script. The end result should be something like this.
How can I achieve this in the load script. I have tried RangeSum functions, but can't seem to get them to work.
Hi, @J_Post
Try this.
-Script
-Result
Reply~! thanks!
https://community.qlik.com/t5/New-to-Qlik-Sense/Cumulative-Sum-in-Script-Qlik-Sense/td-p/1612574
That said, it's often better to do it on the front end so it can react to selections...
https://community.qlik.com/t5/New-to-Qlik-Sense/Running-total-per-dimension/td-p/1542119
There should be more than a few other threads with solutions for this sort of issue if you'd like to search for more.
Add this in your script :-
noconcatenate
Load *, If(Client =previous(Client),Value+peek(Rolling_Sum),Value) as Rolling_Sum resident Table1
order by Client ASC, Month ASC.
I hope your month is in numerical format , if not change it into numerical format of YYYYMM for sorting.
Also, what @Or said, better to do it in UI. using RangeSum and above.
Hi, @J_Post
Try this.
-Script
-Result
Reply~! thanks!