4 Replies Latest reply: Jul 14, 2017 10:31 AM by Aaron Wang RSS

    If then statement in script, evaluates the same

    Aaron Wang

      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

        • Re: If then statement in script, evaluates the same
          Vishwarath Nagaraju

          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
            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