Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey guys, I'm trying to configure some "configuration data" in an excel sheet, and then load them into a qlikview file and turn them into qlikview variables. But I have no Idea how to do it.
What I want is the following :
load * inline [
variable, value
vMin , 1
vMedium , 2
vMax, 3
];
//turn them into variables with the "let" or "set" stuff, but I have no idea about create a variable "vMin" with the value 1, and so on.
Could somebody help me with this stuff? Or the only way to do it is with a macro?
Many thanks in advance!
Try something like the following script:
Expresiones:
LOAD Variable,
Expresion
FROM
Expresiones.xlsx
(ooxml, embedded labels, table is Sheet1);
Let vNroRegistros = NoOfRows('Expresiones');
For vI = 0 to (vNroRegistros - 1)
Let vNombre_Variable = Peek('Variable',vI,'Expresiones');
Let [$(vNombre_Variable)] = Peek('Expresion',vI,'Expresiones');
Next
Regards.
I'm not sure you're going to be able to dynamically define the variable names.
In order to store loaded data in a variable, you would use something like:
I tried a couple of combinations of dollar sign expansions on the variable name, but I couldn't get anything to work.Let vMin = Peek('value', 1)
Set vMin = 1;
Set vMedium = 2;
...
That will allow you to have all of the variable definitions in one place.$(Include=C:\Path\For\Text\File.txt);
In the script, you could put Let vMin = peek('variable',0); and then Let vMedium = peek('variable',1), etc.
Or you don't have to use variables. In the application you can use the expression
only({$<variable={'vMin'}>} value)
Regards.
Thank you both for answer me so quickly.
What I'm trying to do is to load the data with no idea of the names of the variables, it was only a figured example.
Could I put the name of the variable dynamically without knowing the name of the variable?
Many thanks anyway.
Hi Marcel
This might do what you want:
LOAD * INLINE [
Variable, Value
vMin, 1
vMed, 2
vMax, 3
];
let vVariable1 = fieldvalue('Variable', 1);
let vValue1 = fieldvalue('Value', 1);
let $(vVariable1) = $(vValue1);
let vVariable2 = fieldvalue('Variable', 2);
let vValue2 = fieldvalue('Value', 2);
let $(vVariable2) = $(vValue2);
let vVariable3 = fieldvalue('Variable', 3);
let vValue3 = fieldvalue('Value', 3);
let $(vVariable3) = $(vValue3);
Try something like the following script:
Expresiones:
LOAD Variable,
Expresion
FROM
Expresiones.xlsx
(ooxml, embedded labels, table is Sheet1);
Let vNroRegistros = NoOfRows('Expresiones');
For vI = 0 to (vNroRegistros - 1)
Let vNombre_Variable = Peek('Variable',vI,'Expresiones');
Let [$(vNombre_Variable)] = Peek('Expresion',vI,'Expresiones');
Next
Regards.
Many thanks Karl, that was exactly what I was looking for. Loading dynamically variables and their values into the script.
See you around!!