Qlik Community

Ask a Question

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

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

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

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

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

Contributor III
Contributor III

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.