Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Question about Accumulate data with script

I have data something like columns below

   

DateMachine No.TR-RPM
01/01/2017MA0017436
02/01/2017MA0017436
03/01/2017MA0017436
04/01/2017MA0017436
05/01/2017MA0017436
01/01/2017MA0027524
02/01/2017MA0027524
03/01/2017MA0027524
04/01/2017MA0027524
05/01/2017MA0027524
01/01/2017MA0037656
02/01/2017MA0037656
03/01/2017MA0037656
04/01/2017MA0037656
05/01/2017MA0037656

and the result that I need as column result.

    

DateMachine No.TR-RPMresult
01/01/2017MA00174367436
02/01/2017MA001743614872
03/01/2017MA001743622308
04/01/2017MA001743629744
05/01/2017MA001743637180
01/01/2017MA002752444704
02/01/2017MA002752452228
03/01/2017MA002752459752
04/01/2017MA002752467276
05/01/2017MA002752474800
01/01/2017MA003765682456

So How to coding script for accumulate data with column TR-RPM ?

Thank you.

5 Replies
amit_saini
Master III
Master III

Hello,

Use this as expression:

rangesum(above(total sum([TR-RPM]),0,Rowno(TOTAL)))

Thanks,

AS

marcus_sommer

The suggestion from Amit is for using within a chart in the gui which might already suitable for your needs. If you instead want to calculate it within the script you could use peek() for it, like this example:

...

rangesum([TR-RPM], peek('result')) as result

...

within a proper sorted resident-load. More could you find here: Peek() or Previous() ?

- Marcus

ahaahaaha
Partner - Master
Partner - Master

Alternatively, you can use this expression

numsum( [TR-RPM], peek( 'result' ) ) as result

But correct to use rangesum() function as written above Marcus

Not applicable
Author

Thank you all for suggestion,

but I need to use rangesum() with column [TR-RPM] and the answer that I want same as column "result".

I try to use script as below.

rangesum([TR-RPM],peek([TR-RPM],-1))  as result

then the result that I got ,It's not correct.


How to make column "result" to show accumulate data from column TR-RPM?

test.PNG

marcus_sommer

I think you missed the essential requirement for using peek/previous within the above answer:

" ... within a proper sorted resident-load."

- Marcus