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

Help in Peek Function

Hi,

I need help in getting the last row using peek function and below is the sample data.

PeekTest:
LOAD * Inline
[
ID
1
2
3
];

LOAD ID,
Peek(ID,0) as FirstValue
Resident Peek;

By using the above peek function i can able to get the first row into FirstValue field i,e, '1' but when i use 'Peek(ID,-1) as LastValue' i'm getting '1' and '2' but i want to see only '3'.

Can someone help me to identify the issue.

Regards,

Bharath Vikas

 

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Do you need Peek() or can this work instead?

Test:
LOAD LastValue(ID) as LastValue;
LOAD * INLINE [
    ID
    1
    2
    3
];

View solution in original post

6 Replies
sunny_talwar

You want to see just one row with 3 or are you looking to see all three rows with 3 in it?

Frank_Hartmann
Master II
Master II

PeekTest:
LOAD * Inline
[
ID
1
2
3
];

NoConcatenate
Final:
Load * Resident PeekTest Order by ID desc;

LOAD ID,
Peek(ID,0) as FirstValue
Resident Final;
vikasshana
Creator II
Creator II
Author

@sunny_talwar  I want to see one row with 3.

vikasshana
Creator II
Creator II
Author

@Frank_Hartmann  thanks for that, but my requirement is I want first value and last value. It means if i use 'Peek(ID,0) as FirstValue' i want the result as '1' as below

FirstValue
1

 

And if i use 'Peek(ID,-1) as LastValue' i want the result as '3' as below

LastValue
3
sunny_talwar

Do you need Peek() or can this work instead?

Test:
LOAD LastValue(ID) as LastValue;
LOAD * INLINE [
    ID
    1
    2
    3
];
vikasshana
Creator II
Creator II
Author

@sunny_talwar thanks for that, it works for me and i've modified the script a little bit as below in order to get the firstvalue as well.

Test:
LOAD LastValue(ID) as LastValue, FirstValue(ID) as FirstValue;
LOAD * INLINE [
ID
1
2
3
4
];