Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Peek function

Hello,

I use an incremental load to load 3 reports into qlikview. I have written my code so that a table is created with the reports from the latest date for which all reports are available. The table looks like this (in order of loading):

Table1:

file                        report category

filename1                    Category1

filename2                    Category2  

filename3                    Category3

In my script I write the following code:

let vReport1=peek('file',fieldindex('rapport','Category1'),'table1')

let vReport2=peek('file',fieldindex('rapport','Category2'),'table1')

let vReport3=peek('file',fieldindex('rapport','Category3'),'table1')

I would think this code gives me the filename of the file that I want to load, but apparently every vReport leads to the same result; it always results in filename3, even though the fieldindex formula returns a different number. What am I doing wrong here?

Thanks in advance for your help.

4 Replies
swuehl
MVP
MVP

What do the fieldindex() functions return as value for each call?

And what does this return as variables value:

let vReport1=peek('file',0,'table1');

let vReport2=peek('file',1,'table1');

let vReport3=peek('file',2,'table1');

Does your Table1 only holds three records or duplicate records per file?

Not applicable
Author

fieldindex('rapport,'Category1') yields value 1

fieldindex('rapport,'Category2') yields value 2

fieldindex('rapport,'Category3') yields value 3


Table1 only has the 2 fields that I described, filename and category


Please note that I loaded category as right(filename, 6), since the last bit of the filename describes to which category it belongs.


When I load table1 and create a table object, I see no duplicate values. Just the 3 file names and their respective categories.


vReport1=peek('file'0,'table1) also yields filename3. No matter which number I use as a row number in the peek function, it returns the same filename. Even when I use 10, even though there are only supposed to be 3 rows in my table.

swuehl
MVP
MVP

The table box won't show duplicate records. If you open table view CTRL-T, and open preview of that table 1, only 3 distinct records are shown?

I assume you are creating duplicate records in your table 1 creation.

Also note the different indexing start value for peek( zero) vs fieldindex( one ).

Not applicable
Author

Apparently I am many creating many duplicate records, I will try to figure that out first. Thanks!