The code first loads variable names and the contents for the variables from an excel file into the table CommonVariables. In the for-loop it iterates through each record of the table CommonVariables and retrieves the variable name and the variable contents. It the creates the variable in the qlikview document and assigns the variable contents to the variable. The NoOfRows function is used to find the number of records of the CommonVariables table, i.e. the number of variables that should be created. The peek function is used to look up the values of the fields from the i-th record.
just a few words to add for anyone else looking at this - I just spent around 20min figuring out the details
of the code above. Of course it does work, but there are a few loopholes:
- both the name of the variable as you want it and the table_name must be in quotes (that's correct here, but it's
- The field 'VarFormula' that is referenced in the code must contain ONLY the value, not the complete SET command
or anything ... (and keep in mind the decimal_separator_settings in QlikView might not match those in Excel)
- For the first record, i must have the value 0 (not 1) - you can look that up in the help_file, but it's always possible to
get it wrong ;-)