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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

accumulation in script - still struggling

I am attaching the sample qvw file.

I am not getting the counts for LoginsOnThisHost field.

Could somebody please help!!!

1 Solution

Accepted Solutions
Not applicable
Author

After playing with it for some time, here is what seems to be working

Load1:
load * inline
[data1, data2
a,1
b,1
c,-1
d,1
e,-1
b,1
b,-1
a,-1
a,2
a,3
a,4
a,5];

DingoLog:

LOAD *,
    if ( Peek(data1)=data1,Peek(data3)+data2,data2) as data3
    Resident Load1 Order by data1,data2;

DROP Table Load1;

NOTE: There is some strange difference between peek and previous.

View solution in original post

6 Replies
Anonymous
Not applicable
Author

change the 3rd expression as count(LoginsOnThisHos)

bgerchikov
Partner - Creator III
Partner - Creator III

Hi,

your expression shows field value only. Try to use something like

count(LoginsOnThisHost) or Sum(LoginsOnThisHost)

Hope it will help.

Not applicable
Author

Thanks Boris and Srikant.

Making it count or sum just makes the point clearer - i get zeros.

Indeed, i want the field value of loginsonthishost because the accumulation is done in the script using a set of previous functions and ordering the resident load.

Not applicable
Author

Here is a simpler code -

 

Load1:
load * inline
[data1, data2
a,1
b,1
c,-1
d,1
e,-1
b,1
b,-1
a,-1
a,2
a,3
a,4
a,5];

DingoLog:
LOAD *,
    if ( Previous('data1')=data1,Previous('data3')+data2,data2) as data3
    Resident Load1 Order by data1;

Why is this not giving me counts for data3?

bgerchikov
Partner - Creator III
Partner - Creator III

Try to clear selection - you'll see numbers

Not applicable
Author

After playing with it for some time, here is what seems to be working

Load1:
load * inline
[data1, data2
a,1
b,1
c,-1
d,1
e,-1
b,1
b,-1
a,-1
a,2
a,3
a,4
a,5];

DingoLog:

LOAD *,
    if ( Peek(data1)=data1,Peek(data3)+data2,data2) as data3
    Resident Load1 Order by data1,data2;

DROP Table Load1;

NOTE: There is some strange difference between peek and previous.