Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Tags (5)
1 Solution

Accepted Solutions
Not applicable

Re: If then statement in script, evaluates the same

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!

4 Replies
vishsaggi
Esteemed Contributor III

Re: If then statement in script, evaluates the same

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?

Re: If then statement in script, evaluates the same

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

Re: If then statement in script, evaluates the same

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

Re: If then statement in script, evaluates the same

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!

Community Browser