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

cumulative Value while loading

Hi,

I have an Value and time in a small table.

Load

         Value,

         time

from table;

Jan           10

Feb           15

Mar          20

Now I want to accumulate the values for each month, e.g.

Jan          10

Feb          25

Mar          45

I want to do it in script while loading the table, it is possible? Maybe it is too simple and I am thinking in wrong directions.

Thanks in advance

Thomas

4 Replies
Not applicable
Author

RangeSum(Value, Peek('Cumulative')), Value) AS Cumulative

This is what you need while loading.

Hope this helps


Regards

Sravan

pat_agen
Specialist
Specialist

hi,

Sravan's answer works - and is very neat.

i think there is a typo tho' and it should read

RangeSum(Value, Peek('Cumulative')) AS Cumulative

I tested with a preceeding load (see below)

loadData:
load *
, RangeSum(Value, Peek('Cumulative')) AS Cumulative
;

Load * inline
[
time,Value
Jan   ,        10
Feb   ,        15
Mar    ,      20
];


I didn't think it was possible to reference a field which is not present in the data source. But there you go  - not the first time I've learnt something new here!

Not applicable
Author

Thank you very much, Sravan, it works

christian77
Partner - Specialist
Partner - Specialist

Hi:

It is always better to do calculations in the script since you obtain those as a field.

In the case of cumulative fields there is an inconvenience.

If you want to apply a filter like Kind, Class, Type, Account, Client, etc, then your cumulative field just won’t work.

In that case, you’ll have to cumulate in the table, using inter record functions.

Ok.