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

How to create a cumulate field loading a table?

Hallo you all,

could you help me? I'm facing with the following problem.

I'm able to calculate the B accumulate value in column "B_cumul" using a chart object.

I need to to do the same job, but using the script in the loading stage (create the field B_cumul)

result using chart object:


xls table source:

A                           B

a5
b8
c3
d4

scripting:

Directory;

T1:

LOAD

     A,

     B

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1);

Thank you in advance for your time

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Directory;

T1:

LOAD

     A,

     B,

     rangesum(B, peek('C')) as C

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1);

If you need to have B order in ascending order first and the cumulative calculated using that order then you need to load the excel data first and then use a resident load to reorder the data and calculate the cumulative:

T1:

LOAD

     A,

     B

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1);

Result:

LOAD *, rangesum(B, peek('C')) as C

RESIDENT T1

ORDER BY B;


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Directory;

T1:

LOAD

     A,

     B,

     rangesum(B, peek('C')) as C

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1);

If you need to have B order in ascending order first and the cumulative calculated using that order then you need to load the excel data first and then use a resident load to reorder the data and calculate the cumulative:

T1:

LOAD

     A,

     B

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1);

Result:

LOAD *, rangesum(B, peek('C')) as C

RESIDENT T1

ORDER BY B;


talk is cheap, supply exceeds demand
rbecher
MVP
MVP

Another simple variant:

LOAD A,

     B,

     Alt(Peek('C'),0) + B as C

FROM

[..\..\..\elimina\testcum.xlsx]

(ooxml, no labels, table is Foglio1)

;

- Ralf

Astrato.io Head of R&D
Not applicable
Author

Hallo,

thank you very much, it works perfectly!

The power of the knowledge sharing.

Thanks again