Databases Reference
In-Depth Information
When defining our set variables in the script, we must be very cautious because
of the presence of the dollar sign inside the variable's text. If we were to use the
dollar sign directly inside the variable's definition, QlikView would interpret it as
something to be expanded in the process, causing the load script to fail. Therefore,
we have avoided the insertion of this symbol and used a string function instead.
Chr(36) results in the dollar sign, as it is the ASCII character used to represent the
symbol. The resulting string is concatenated to the rest when the variable is defined.
We have also inserted line breaks with the Chr(10) function.
We will name the text file as SetVariables.txt and store it in the same location as
the Airline Operations document.
A copy of the finished SetVariables.txt has been
included into the Airline Operations\Apps folder.
Now that we have the text file, we will include it into our script using the
following statement:
$(Include=SetVariables.txt)
Relative or full paths can be used with the Include statement.
Double-check the file path when using this statement, as there
are no error messages when the specified file is not found.
When we run the script, the corresponding variables will be created and are ready
to be used on the chart's expressions. The same statement could be used on any
QlikView document to make them execute the same SetVariables.txt script and
share the same set variables across them.
An alternative method for defining variables in an external
file and loading them into QlikView is described in Barry's
blog at http://www.qlikfix.com/2011/09/21/
storing-variables-outside-of-qlikview/ . Be sure
to check that out too.
Set variables and the Master Calendar
As the set variables created with the preceding script are based on field names, all of
those fields must exist (preferably in a Master Calendar table) in the document that
uses the variables, otherwise they will not work as expected. Therefore, we advise
you to integrate both the set variables and the Master Calendar scripts into a single,
generic script stored in a text file to be called from any QlikView document, ensuring
consistency and functionality.
 
Search WWH ::




Custom Search