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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If Then syntax in script


I have the following IF statement:

mod($(vInterpreted_Date_Range), 66) = 0, eLoad_Iterations = (div $(vInterpreted_Date_Range), 66), eLoad_Iterations = ((div($(vInterpreted_Date_Range), 66) + 1));

Is there anything egregiously wrong with this and also, can a statement such as this be in the script?

6 Replies
tresesco
MVP
MVP

I guess missing parenthesis would be major issue. One example:

div $(vInterpreted_Date_Range),  -> missing one (). Div ( .... ).

Try to share your complete IF statement.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

tresesco is correct. What does the variable contain?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Peter_Cammaert
Partner - Champion III
Partner - Champion III

The format of your specification is weird. Everything is wrong with it, especially the missing IF keyword.

There are two types of IF's in QlikView scripting language:

  • There is an IF () function (really!) that takes expressions but not assignments in the True/False parts. Note that those parts should be specified as (sometimes optional) parameters and that this function can be used wherever functions are allowed, e.g. in all expressions.
  • There is an IF statement that comes with a lot of other keywords (ELSEIF, END IF, ENBIF, ELSE...) but that's a so-called Control statement and to be ok, your assignments must be preceded by either LET or SET.

From your question, we cannot make out what sort of IF you're talking about. That's why you should post the complete "statement".

Not applicable
Author

Peter,

The 'IF' part got cut off when I copied and pasted it for some reason.

Below is the complete statement:

  • IF(mod($(vInterpreted_Date_Range)), 66) = 0, eLoad_Iterations = (div

$(vInterpreted_Date_Range), 66), eLoad_Iterations =

((div($(vInterpreted_Date_Range), 66) + 1)); *

I could see adding the LET statements in front of each eLoadIterations, but

for some reason the script editor does not like the parenthesis right

before ", 66" in the condition part of the statement.

I tried this:

If

(mod($(vInterpreted_Date_Range)), 66) = 0 THEN LET eLoad_Iterations =

(div $(vInterpreted_Date_Range), 66);

ELSE

LET eLoad_Iterations = ((div($(vInterpreted_Date_Range), 66) + 1));

*ENDIF *

*but it still does not like the mod statement (it gives the red squiggly

line under the second parens after vInterpreted_Date_Range in *

(mod($(vInterpreted_Date_Range)), 66) = 0

can I not use an expression for the condition?

Not applicable
Author

Peter,

I actually got it figured out. I changed the IF function to the IF, THEN,

ELSE kind (where those words were typed out) and I had some "Paren-disease"

going on as well. Well, truthfully I just had a parens before a comma that

was causing all the trouble. Thanks!!

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Great! The answer is often hidden in the little details ("Argh, those d*mn punctuation marks!"...) Just wait til you start playing with set analysis

Please close the discussion by marking an answer as correct/helpful. That'll make it useful for other community visitors. Thanks.

Peter