Skip to content

Instantly share code, notes, and snippets.

@gsbeaton
Last active July 31, 2019 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsbeaton/8a9605e411ad2d10eaefe1876f3e03c2 to your computer and use it in GitHub Desktop.
Save gsbeaton/8a9605e411ad2d10eaefe1876f3e03c2 to your computer and use it in GitHub Desktop.
A QlikView and QlikSense script to generate variables from a CSV include.
/*
| -------------------------------------------------------------------
| Create Variables
| -------------------------------------------------------------------
| Loads data from the Variables repository and loops through to
| create a valid variable for each row of the repo.
|
| Set your CSV doc up like this:
|
| VariableName, VariableValue, Comments
| vUserName, "SubField(OSUser(),'\',2)", "The logged on user's name"
| vSheetNameHelper, "if(GetActiveSheetId()=$1,'pass','fail')"
|
*/
Variables:
LOAD VariableName
,VariableValue
,Comments
FROM
[..\QVS_Source\Variable_Repo.csv]
(txt, utf8, embedded labels, delimiter is ',', msq);
// create the variables for the application security.
FOR i=0 to NumMax(NoOfRows('Variables'),0)-1;
LET TempVarName = peek('VariableName',$(i),'Variables');
LET $(TempVarName) = peek('VariableValue',$(i),'Variables');
NEXT
LET TempVarName = NULL();
LET TempVarValue = NULL();
DROP Table Variables;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment