Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
@Hi,
I stumbled across this code while studying a dashboard built by another developer.
At a high level I thing I know ( I'm not sure ) what happening in this code.
Has anyone used this code before
Could someone explain what's happening here.
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.
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.
Hello.
The code does exactly what you think: it does create new variable inside the loop.
The purpose of it, i guess, is that you can maintain a single xls full variables common to all your application and use the code to load the variables from the excel file.
Regards
This code opens a excel file and creates as many variables (one per line) as rows on [Common Variables] sheet
Hi,
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
important)
- 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 😉
HTH
Best regards,
DataNibbler