Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If then statement in script, evaluates the same

ifthen.png

For some reason, and I've tried many scenarios, the above always sets BuildQvd to true.

I have ValueSources in the path file, yet it still builds it each time.

Any idea why?

Thank you

1 Solution

Accepted Solutions
Not applicable
Author

I was having issues with it always evaluating to the same value.

This is what fixed it.

If the file doesnt exist, the records will be null, not zero.

let vQVDExists = not isnull(QvdCreateTime('filepath.qvd'));

if $(vQVDExists) = 0 then

..........

END IF

Thanks!

View solution in original post

4 Replies
vishsaggi
Champion III
Champion III

Correct me not sure i understand your query.

Your script says if no of records from Values_Sources is > 0 then

you want to set your vBuildQVD = 'False' ELSE

                                 vBuil,dQVD = 'True'.

You dont have any records in your table. So it always be true. So what exactly you are trying to do?

marcus_sommer

I think the reason are missing single-quotes and a $-sign expansion around your variable which are needed if the variable contained string-values. It should be look like:

...

if '$(vBuildQVD)' = 'True' then

...

Whereby in your above scenario you don't need these variables - you could directly use the first if with the QVDNoOfRecords to switch in your different branches.

Beside them it's quite often useful to create numeric or even better boolean variables instead of strings. In your case it could be for examples:

let vBuildQVD = ceil(QVDNoOfRecords('path/file.qvd') / 100000000000);

which returned 0 respectively FALSE if there is no record and 1 respectively TRUE if there is any record (whereby each number unless 0 will be in Qlik treated as TRUE).

- Marcus

Not applicable
Author

If I'm not mistaken, QvdNumberofRecords returns the records in that qvd. So since I already have that qvd with data in it, it should be greater than 0, so then it doesnt rebuild the qvd from scratch

Not applicable
Author

I was having issues with it always evaluating to the same value.

This is what fixed it.

If the file doesnt exist, the records will be null, not zero.

let vQVDExists = not isnull(QvdCreateTime('filepath.qvd'));

if $(vQVDExists) = 0 then

..........

END IF

Thanks!