3 Replies Latest reply: Mar 24, 2011 1:26 AM by Miguel Angel Baeyens de Arce RSS

    Add Environmental variable

      Hi,

      Is it possible to modify the list of Enrvironment / System variables across all qlikview documents?

      I have created a variable that, based on the location of the current document, displays the path to the data store (For ease of portability of QVW's between live and development environments on the same QV server). I would like to include this variable declaration statement in all new Qlikview documents, for all of our 5 developers.

      I have seen the use of a statement to call expressions stored in an external spreasheet, but this still requires developers to add this statement into each QVW... is there a way to automate adding this statement for each new QVW?

      Many Thanks

      Tom

        • Add Environmental variable
          Miguel Angel Baeyens de Arce

          Hello Tom,

          I'd use the Include variable after (or instead of) the existing variables in a new document, at the top of the script:

           

          $(Include=EnvVariables.txt)


          Where the EnvVariables.txt file stores the variables localized to be used in each location.

          Hope this helps.

            • Add Environmental variable

              The other solution is to prepare a flat file (or xls,...) with 2 column (VAR_NAME, VAR_VALUE) and proceed with following script:

              RPT_VARS:
              SQL SELECT
              VAR_NAME,
              VAR_VALUE
              FROM REPORT_VARIABLES;

              Let RowCount = NumMax(NoOfRows('RPT_VARS'),0)-1;
              For i=0 to '$(RowCount)'
              Let TempVarName = peek('VAR_NAME',$(i),'RPT_VARS');
              Let TempVarValue = peek('VAR_VALUE',$(i),'RPT_VARS');
              Let $(TempVarName) = '$(TempVarValue)';
              next

              Source: http://qlikviewmaven.blogspot.com/2008/12/loading-variables-via-loadscript.html

              I don't know if there would be performance issue, but (if I am not wrong) the include feature imposes that we follow QV syntax (such as):

              SET var1=5;
              SET company=ABC Corp;

              ....

                • Add Environmental variable
                  Miguel Angel Baeyens de Arce

                  Hello Nicolas,

                  My purpose with the include is exactly that, that is, chaging the already existing variables in the script, to get localized number/date/money formats, even month names. I may have missed the actual requirement, though.

                  Syntax for QlikView has to be respected, so yes, the plain text in the Include case must contain script. Include doesn't do only for variables, but for any piece of script you want to load from an external file.

                  Anyway, my guess is that performance of the include variable is always better than the other, because, at the end of the day, what you are doing is the same, but by means of a loop (slower), and eventually it does

                   

                  LET TempVarName = TempVarValue;


                  what is, if you take a look at the code, what is already wirtten in the Include file. So why not doing it directly?

                  Again, if I missed the point just ignore the post.

                  Regards.