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

DO LOOP STATEMENT PROBLEM

Hi community.

Please i have a problem with a do loop statement.

This is mi statement:

LET i = 1;
SET ch = "=";

DO while NOT IsNull(FieldValue('RV', i))

IF(i<>1, $(ch)&"+");

$(ch) = $(ch) & 'SUM({$<COMPTE={' & FieldValue('RV', i) & '*}>} DEBIT_CLO)';

i = i + 1;

LOOP

When i reload my qlikview application, this error is displayed :

Error in expression:
')' expected
IF(i<>1, =&"+")

Please i want your help.

Thanks.

9 Replies
gandalfgray
Specialist II
Specialist II

I don't understand the purpose of the first line inside your loop:

IF(i<>1, $(ch)&"+");

What is that supposed to do?

Not applicable
Author

In fact, CH is a string.

I'd like that if the value of the variable i is different from 1,

which is concatenated to the end of the chain CH character '+'

gandalfgray
Specialist II
Specialist II

Maybe something like this:

Let i = 1;
Let ch = "=";
do while Not IsNull(FieldValue('RV', i))
if i > 1 then
Let ch = '$(ch)+';
end if
Let ch = '$(ch)SUM({$<COMPTE={"' & FieldValue('RV', i) & '*"}>} DEBIT_CLO)';
i = i + 1;
loop


Not applicable
Author

Hello YIMEN,

you are coding a load-script. There is another syntax as you know from expressions. For ex. the IF-Statements are quite different. Take a look at my script snippet to get a direction:


LET i = 1;
SET ch = "=";

DO while i<3
IF(i<>1) THEN
LET ch= $(ch) & '+';
ENDIF;
TRACE --> $(i): $(ch);
LET i= $(i) +1;
LOOP;



HtH

Roland

Not applicable
Author

Please Roland, can you explain me every statement of your script

Thanks in advance.


Roland Kunle wrote:
Hello YIMEN,
you are coding a load-script. There is another syntax as you know from expressions. For ex. the IF-Statements are quite different. Take a look at my script snippet to get a direction:
<blockquote><pre>
LET i = 1;
SET ch = "=";

DO while i<3
IF(i<>1) THEN
LET ch= $(ch) & '+';
ENDIF;
TRACE --> $(i): $(ch);
LET i= $(i) +1;
LOOP;

HtH

Roland

Not applicable
Author

Please GORAN, How do I see the contents of the variable CH

[quote user="Göran K"]

Maybe something like this:

Let i = 1;
Let ch = "=";
do while Not IsNull(FieldValue('RV', i))
if i > 1 then
Let ch = '$(ch)+';
end if
Let ch = '$(ch)SUM({tiny_mce_markerlt;COMPTE={"' & FieldValue('RV', i) & '*"}>} DEBIT_CLO)';
i = i + 1;
loop

gandalfgray
Specialist II
Specialist II

There are several ways:

- you can load in debug mode and inspect the variable ch for each step.

- in your loaded application you can see the variable ch using Ctrl+Alt+V

Not applicable
Author

Hello Yimen,

the syntax of the IF in script is

IF ... THEN ... ENDIF

What you are searching for is the

TRACE $(variable)

to see what is in your variable. And to count your running I use the LET - Statement within the LOOP.

RR

Not applicable
Author

Thanks Sir KUNLE