Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Trouble with IF-statement

Hi,

my rule is that if a record for a certain day (say, 12.8.2013 which is 41498 in number format) is already contained in the field NumericDate, no further action needs to be done. If the record is not contained, some calculations should be done.

The problem is that the IF is not working like it should [that is, if I created it correctly]: the qvd Testi1 contains the value of the variable (=41498) in the NumericDate-field. Still, the screen captures (left showing execution of the statement and right showing that the condition of the IF did not work as expected because execution went into ELSE-part) indicate that something is wrong.

Can someone think of an error in the IF-statement?

Any help appreciated,

Juho

1.PNG2.PNG

1 Solution

Accepted Solutions
Not applicable
Author

Hi Juho,

- the parameters of Exists are Fieldname and Expression and noth should be in single quotes.

So in your case try similar to this:

IF (Exists('MyDateField', '$(MyVar)')) then

    TRACE Heureka;

ENDIF;

Regards

Roland

View solution in original post

3 Replies
Not applicable
Author

Hi Juho,

- the parameters of Exists are Fieldname and Expression and noth should be in single quotes.

So in your case try similar to this:

IF (Exists('MyDateField', '$(MyVar)')) then

    TRACE Heureka;

ENDIF;

Regards

Roland

tresesco
MVP
MVP

A better look at your script, tells me that, you are using the order of the parameters in the EXISTS function wrong. Try:

If( exists (NumericDate, '$(vDateOfReload'))  Then

Anonymous
Not applicable
Author

Roland and Tres, the IF now works thanks to you!

I actually tried to use    

     IF (Exists(MyDateField, '$(MyVar)'))

before beginning this discussion, but I could not figure out that both parameters should be inside single quotes.