Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
Is it possible to use the peek function with variable. Need to dynamically specify the column position(Row number which the data has to be picked)
For e.g
i can define in loop like this
let e=1
do while e<=10
let c= peek('column',$(e),'Table' )
let e=e+1;
loop
hi XXX,
Yes its possible. but you need to add e variable to c. Hence you will have multiple variable.
PFA.
Deepak
Thanks for your response Deepak.
It is fine for the first value not for the second value.It is not storing the next value .
Is there any way i can store like this
Let vRecord= Load id Resident table;
Please find my scrip i have used
Tabledata:
LOAD id,
Filelocation FROM (biff, embedded labels, table is Sheet1$); Tabledetails: LOAD max(id) as maxid FROM (biff, embedded labels, table is Sheet1$); Let x=Peek('maxid' ,0,'Tabledetails'); Let a=1; Do while a<=x flocation: Load Filelocation Resident Tabledata where id=$(a); Let filocation= Peek('Filelocation' ,0,'flocation'); Finaltable: LOAD * FROM $(filocation); let a=a+1; loop File location when a =1 it is fine .But for a=2 it is null. So the second row data is not getting loaded. Please suggest,
Thanks for your response Deepak.
It is fine for the first value not for the second value.It is not storing the next value .
Is there any way i can store like this
Let vRecord= Load id Resident table;
Please find my scrip i have used
Tabledata:
LOAD id,
Filelocation FROM (biff, embedded labels, table is Sheet1$); Tabledetails: LOAD max(id) as maxid FROM (biff, embedded labels, table is Sheet1$); Let x=Peek('maxid' ,0,'Tabledetails'); Let a=1; Do while a<=x flocation: Load Filelocation Resident Tabledata where id=$(a); Let filocation= Peek('Filelocation' ,0,'flocation'); Finaltable: LOAD * FROM $(filocation); let a=a+1; loop File location when a =1 it is fine .But for a=2 it is null. So the second row data is not getting loaded. Please suggest,
hi,
Because u need to create array of variable like below
fillocation$(a) = peek('FileLocation',$(a),flocation)
I do something similar to this with for loops. Not sure exactly how much this relates to what you want to do but here's an idea:
Tables:
FIRST 1 LOAD DISTINCT
filename() as 'File',
QVDNoOfFields('$(vPath)' & filename()) as 'Field Count'
FROM
(qvd);
For i = 1 to NoOfRows('Tables')
LET vFileName = peek('File',$(i)-1,'Tables');
LET vFieldCount=peek('Field Count',$(i)-1,'Tables');
QVDs:
FIRST 1 LOAD DISTINCT
filename() as 'qvd',
filetime() as 'qvd Time',
date(left(filetime(),index(filetime(),' ')-1)) as 'qvd Date',
qvdNoOfFields('$(vPath)' & filename()) as 'qvd Number of Fields',
evaluate(filesize('$(vPath)$(vFileName)')/1048576) as 'qvd File Size (mb)',
QvdNoOfRecords('$(vPath)$(vFileName)') as 'qvd No of Records'
FROM
$(vPath)$(vFileName)
(qvd);
Next
XXX,
I believe this is the same concept as reading through a spreadsheet to create multiple variables for expressions.
You can adapt the code to fit the resident file.
http://community.qlik.com/message/115347#115347
Regards,
Rich