Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

script error of peek function

Hello,

     i am using qlikview v11.

i got currency script from forum that i have pasted below.but it showing script error . this error might be of peek function.

Let zMaxExchangeDate = peek('MaxExchangeDate');

zMaxExchangeDate showing null.

I have attach error msg pls find

Pls help

T_LastDate:

LOAD

max([End Date]) As MaxExchangeDate

From 'E:\Currency\HisCurrency.qvd'(qvd);

Let zMaxExchangeDate = peek('MaxExchangeDate');

DROP Table T_LastDate;

For zi = zMaxExchangeDate + 1 to Today()

   Let dd = Date(zi, 'MM/DD/YY');

    

     [HisCurrency]:

     LOAD

     Date(Today())   as [End Date],

                                                     

     [Units/1 USD]     as [USD/KES],

     Year(Today())  as Year,

     Month(Today())  as Month,

     Day(Today()) as Day,

     Week(Today())  as Week,

     WeekYear(Today()) & '-' & Num(Week(Today()),'00')   as RollingWeek,

     Weekday(Today())  as WeekDay,

     Date(MonthStart(Today()),'YYYY-MM')    as RollingMonth,

        Right(year(Today()),2) & '-Q' & ceil(Month(Today())/3) as [YearQtr],

     'Q' & Ceil(Month(Today())/3)  as Quarter

  

  

   

    FROM  [http://www.oanda.com/convert/fxdaily?date=$(dd)&date_fmt=us&exch=USD&lang=en&sel_list=KES&value=1&fo...]

    (html, codepage is 1252, embedded labels, table is @1);

   

Next

Concatenate (HisCurrency)

LOAD * From HisCurrency.qvd (qvd)

Where Not(Exists([End Date]));

Store [HisCurrency] into HisCurrency.QVD;

3 Replies
Not applicable
Author

You didn't attached the error, but since you're using peek outside of the Load, you need to indicate which row value you want to set in the variable and which table this value comes from. The peek function without the row parameter (second) and table name parameter(third) can only be used inside the load section of a table.

I think your script should work with the next:

Let zMaxExchangeDate = peek('MaxExchangeDate',0,'T_LastDate');

Not applicable
Author

thank u  for replying & Sorry  i forgot to attach error.

actualy in variable zMaxExchangeDate 

null is coming and therefore it is showing error to for loop as below

Script line error:

For i = zMaxExchangeDate + 1 to Today()

why is this so can u explian.

Thank u

Not applicable
Author

I'm not sure... but are you certain that your "T_LastDate" table loads any values? If it doesn't, that's why the peek function is returning a null value. I'd check the from section of the "T_LastDate" table... I think the single quotes shouldn't be there.