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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Previous() ?

Hi all,

i have a table like this:

YQ#People
2012-Q13
2012-Q25
2012-Q33
2012-Q46

i want to have a table where "#People" is always the current value plus the previous one, so that it looks like this:

YQ#People
2012-Q13
2012-Q28
2012-Q311
2012-Q417

I tried to do it with:

#People + previous(#People) as #People

but this did not work.

What am i doing wrong ?

Thanks a lot!

K

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

you have to just create a new field. modify your load statement like :

Load *,

        

         #People + previous(#PeopleNew) as #PeopleNew

Resident .....;

Thanks.

View solution in original post

5 Replies
Not applicable
Author

need to do this in the LOAD script...

Sokkorn
Master
Master

Hi kalinkula,

This script should work

[Data]:

LOAD * INLINE [

YQ,             #People

2012-Q1,    3

2012-Q2,    5

2012-Q3,    3

2012-Q4,    6];

[Data2]:

LOAD

    YQ               AS [YQ2],

    [#People]    AS [#People2],

    RangeSum([#People], Peek('#People3'))    AS [#People3]

Resident [Data];

Regards,

Sokkorn

tresB
Champion III
Champion III

you have to just create a new field. modify your load statement like :

Load *,

        

         #People + previous(#PeopleNew) as #PeopleNew

Resident .....;

Thanks.

Not applicable
Author

Thanks a lot!

This works - however: What do i doo if i have two quarters where i have Null() values, like for example, replace Q2 and Q3 with null values: How can i put '3' in those two records ?

regards,

K

Sokkorn
Master
Master

Hi,

That should work like you mention. Anyhow, if it not work, you can try

NumSum(RangeSum([#People], Peek('#People3')))    AS [#People3]

Regards,

Sokkorn