Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

getting max value from table and storing to a variable in script.

Dear Team,

i want to get max value from a table assign that value to a variable and then use same variable to a load statement. please help what i am doing wrong i am getting null value in the variable.

temp:

LOAD max(WEEKNO) as maxWeekNo Resident tbl_WeeklyData;

let v14WeekNo = Previous(maxWeekNo);

tbl_14WeekInfo:

LOAD SC_CODE,

     SC_CODE_M,

     SC_NAME,

     SC_GROUP,

     SC_TYPE,

     AVG_NO_OF_SHRS,

    // if(AVG_NO_OF_SHRS > 10000, '>10000', '<=10000')  as Flag,

     WEEKYEAR_KEY Resident tbl_WeeklyData

     Where WEEKNO = $(v14WeekNo);

    

  DROP Table temp;

1 Solution

Accepted Solutions
satyadev_j
Specialist
Specialist

Hi,

Try below,

let v14WeekNo = Peek('maxWeekNo', 0, 'temp')

View solution in original post

3 Replies
datanibbler
Champion
Champion

Hi Jitendra,

try not putting your  variable v14WeekNo into brackets - it is a simple number, isn't it? That doesn't need dollar-sign-expansion. Play around a bit with that, it can be - different from what you'd expect 😉

Have you tried setting a Breakpoint ("EXIT SCRIPT") to make sure your variable exists and has the value you want?

satyadev_j
Specialist
Specialist

Hi,

Try below,

let v14WeekNo = Peek('maxWeekNo', 0, 'temp')

View solution in original post

Not applicable

Thanks Satyadev, Actually i was using peek only but forget to provide the single quote "'" in the peek function//