Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Mattia
Creator II
Creator II

Why Peek() don't work with Preceding Load?

Hi guys,

i'm in trouble because i notice that Peek() don't work with Preceding load and i don't know why.

Load
If(COUNT=Peek(COUNT),Peek(PROG)+1,1) as PROG,
*
Where Len(Trim(CODE))>0;

The output i want is the following: for every COUNT a numerical sequence (PROG) if the CODE>0.

Now, all the PROG=1.

What's my mistake?

Thanks,

Mattia

Labels (3)
4 Replies
Taoufiq_Zarra

Hi Mattia,

I didn't understand your question very well, maybe with an example I can understand it well.

otherwise Peek() in Qlik: finds the value of a field in a table for a row that has already been loaded or that exists in internal memory.

while in your function you use If(COUNT=Peek(COUNT),Peek(PROG)+1,1) as PROG

so you test on a value that is not yet loaded in memory "COUNT=Peek(COUNT)".

think about using "Resident".

I hope this will help you.

Taoufiq

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Stoyan_Terziev
Partner - Creator III
Partner - Creator III

Hi Mattia,

 

What you've written down is a code that identifies if the previous row is the same number.

For this to work properly, you may want to order your data by the column [COUNT] like this:

(script below is plug-and-play)

TestData:
Load * INLINE [
COUNT
101
102
103
103
104
105
105
105
106
];


Transformed:
NoConcatenate
Load
If(COUNT=Peek(COUNT), Peek(PROG)+1,1) as PROG,
COUNT
Resident TestData
ORDER BY COUNT ASC
;

DROP TABLE TestData;

 

Results:

image.png

 

Keep in mind, if you only get 1's - you can check if you have only unique values in the column COUNT.

I hope that helps!

 

Kind regards,

S.T.

Mattia
Creator II
Creator II
Author

Hi guys and thanks for the suggests.

I'm sorry but i'm not able to solve this problem.

If you can, the original problem is the following:

https://community.qlik.com/t5/QlikView-Scripting/How-can-i-insert-this-expression-in-the-load/td-p/1...

Please, help me!!!

Thanks,

Mattia

Sue_Macaluso
Community Manager
Community Manager

@Mattia Hi, it seems the post your linking to has been deleted, please provide the needed details. Thank you

Sue Macaluso