Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 ??
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
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?
@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
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