Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
stanish
Contributor II
Contributor II

Qlik Sense Enterprise - Peek function and resident loads is not working as expected

The Peek function doesn't work as expected. 

I am creating a cumulative sum of the "qty" column. I am using the self column to sum it with itself within the same "sno". when the "sno" changes, I start afresh.

Please give a fix.

 

Test:
LOAD
*
FROM [lib://DataFiles/Book (2).xlsx]
(ooxml, embedded labels, table is Sheet1);

Test2:
LOAD
sno as sno1,
qty as qty1,
if(RowNo()=1,qty,
if(sno = peek(sno), qty + peek(Cumulative_qty,-1), qty )) as Cumulative_qty
resident Test;

 

3 Solutions

Accepted Solutions
danielrozental
Master II
Master II

Please try something like this. Peek(sno) doesn't work because column sno doesn't exists in the output data, but you can use previous.

I would also recommend sorting by sno just in case file doesn't come ordered.

 

Test:
LOAD
*
FROM [..\..\..\Downloads\Book (2).xlsx]
(ooxml, embedded labels, table is Sheet1);

Test2:
LOAD
sno as sno1,
qty as qty1,
if(sno = previous(sno), qty + peek(Cumulative_qty), qty ) as Cumulative_qty
resident Test
order by sno;

View solution in original post

MarcoWedel

 

Test:
LOAD
*
FROM [lib://DataFiles/Book (2).xlsx]
(ooxml, embedded labels, table is Sheet1);

Test2:
LOAD
sno as sno1,
qty as qty1,
if(RowNo()=1,qty,
if(sno = peek(sno1), qty + peek(Cumulative_qty,-1), qty )) as Cumulative_qty
resident Test;

View solution in original post

Vegar
MVP
MVP

I am glad you guys found a solution for this.I see that you have moved from peek() to previous (), but I just want to point out an syntax error that didn't  get mentioned in your original post.

If you were to peek a field named sno,  then the correct syntax would be Peek('sno'). It takes the string name as a parameter not the field it self.

 

 

View solution in original post

5 Replies
anat
Master
Master

 peek function using in 2 places,which peek is not functioning as expected?

if(RowNo()=1,qty,
if(sno = peek(sno), qty + peek(Cumulative_qty,-1), qty )) as Cumulative_qty

stanish
Contributor II
Contributor II
Author

peek(sno) 

danielrozental
Master II
Master II

Please try something like this. Peek(sno) doesn't work because column sno doesn't exists in the output data, but you can use previous.

I would also recommend sorting by sno just in case file doesn't come ordered.

 

Test:
LOAD
*
FROM [..\..\..\Downloads\Book (2).xlsx]
(ooxml, embedded labels, table is Sheet1);

Test2:
LOAD
sno as sno1,
qty as qty1,
if(sno = previous(sno), qty + peek(Cumulative_qty), qty ) as Cumulative_qty
resident Test
order by sno;

MarcoWedel

 

Test:
LOAD
*
FROM [lib://DataFiles/Book (2).xlsx]
(ooxml, embedded labels, table is Sheet1);

Test2:
LOAD
sno as sno1,
qty as qty1,
if(RowNo()=1,qty,
if(sno = peek(sno1), qty + peek(Cumulative_qty,-1), qty )) as Cumulative_qty
resident Test;

Vegar
MVP
MVP

I am glad you guys found a solution for this.I see that you have moved from peek() to previous (), but I just want to point out an syntax error that didn't  get mentioned in your original post.

If you were to peek a field named sno,  then the correct syntax would be Peek('sno'). It takes the string name as a parameter not the field it self.