Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Problems with a variable in macro script.

Hello,

I have the following problem:

for P=0 to NoOfRows('Pol1')-1
LET vPOLICY_ID = chr(39)&Peek('POLICY_ID',$(P),Pol1)&chr(39);

Pol2:

Load "POLICY_ID" as POLICY_ID2,
SQL select POLICY_ID, ANNEX_ID, COVER_TYPE, INSR_TYPE
FROM "INSIS_OMN"."GEN_RISK_COVERED"

where POLICY_ID=$(vPOLICY_ID);

NEXT P

---------------------------------------------------

The problem is that at the first P=0, my peek function is working and my vPOLICY_ID variable gets the content of Peek('POLICY_ID',$(P),Pol1)

But after NEXT P statement, P takes the value 1, and my variable vPOLICY_ID becomes NULL. This happens for each P different with 0.

Note that my "Pol1" table has a lot of data inside.

I have tried not to use P for peek, and to give 0,1,2... instead of $(P) and my peek function works fine...

Can someone detects where is the problem?

Thank you,

Silviu

1 Solution

Accepted Solutions
Not applicable

Problems with a variable in macro script.

I have solved the problem.

The table name in function PEEK must be without ''.

Thank you,

Silviu.

2 Replies
MVP
MVP

Problems with a variable in macro script.

Silviu,

code like you posted above worked just fine at my side (with my, different table data of course):

for P=0 to NoOfRows('Pol1')-1

LET vPOLICY_ID = chr(39)&Peek('POLICY_ID',$(P),'Pol1')&chr(39);

NEXT P

Note that I enclosed the table name in single quotes (third parameter to the peek function), not sure if that is causing the problem, but could do.

Regards,

Stefan

Not applicable

Problems with a variable in macro script.

I have solved the problem.

The table name in function PEEK must be without ''.

Thank you,

Silviu.

Community Browser