Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
GnaneswarReddy
Contributor III
Contributor III

Peek Function not working as Expected

T1:
Load * inline
[
A,Volume
1,2134
2,124124
3,45345
4,6363
5,364363
];

NoConcatenate


T2:
Load A,
Peek(Volume) as P1,
Previous(Volume) as P2
resident T1
where A >1 ;

 

 

OutPut:

A,P1,P2

2,-,,2134
3,-,124124
4,-,45345
5,-,6363

 

Why am I getting Nulls in P1  ??

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

Peek() fetched the values from the specified table - if no table is specified the current table is taken and if the field isn't loaded there it has nothing to access to ... So it depends on the use-case which interrecord-function is more suitable. Peek() is mainly used for creating new fields, for example by accumulating anything or if not the previous record is taken else anyone which specified within the second parameter.

Further to make sure that the interrecord-feature worked like expected you should always add an appropriate order by statement to ensure the wanted load-order.

- Marcus

View solution in original post

3 Replies
justISO
Specialist
Specialist

Hi,
What you want to achieve with this peek() function in a first place?
The peek() function usually is used to find specific value from your data. So, for example, line

peek('Volume',0,'T1') as P1

will provide you first value of 'Volume' column from table 'T1'. In your case I believe you are trying to see all 'Volume' values and Previous ones, so instead of

peek(Volume) as P1

simple

Volume as P1

wouldn't be  enough?

GnaneswarReddy
Contributor III
Contributor III
Author

@justISO  - I am playing around with Peek and Previous and wanted to see how they work when I Use WHERE 

and when Im using

T2: Load A,Volume
Peek(Volume) as P1,
Previous(Volume) as P2
resident T1
where A >1 ;

So i'm just trying to understand why I am getting Nulls when i am not using Field Volume in T2 Table

 

marcus_sommer

Peek() fetched the values from the specified table - if no table is specified the current table is taken and if the field isn't loaded there it has nothing to access to ... So it depends on the use-case which interrecord-function is more suitable. Peek() is mainly used for creating new fields, for example by accumulating anything or if not the previous record is taken else anyone which specified within the second parameter.

Further to make sure that the interrecord-feature worked like expected you should always add an appropriate order by statement to ensure the wanted load-order.

- Marcus