Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Consider an excel sheet as below, contains 2 columns one for variable name and other for variable expression.
This has to be loaded into qlik and these variables vA,vB,vC has to be created. I have done this using for loop as follows:
vars:
LOAD
VarName,
VarExpression
FROM [lib://new path/variables.xlsx]
(ooxml, embedded labels, table is Sheet1);
for i=0 to NoOfRows('vars')-1;
vVar_name=peek('VarName',$(i),'vars');
vVar_expression=peek('VarExpression',$(i),'vars');
let $(vVar_name)='$(vVar_expression)';
next i;
exit script;
The problem is in the vB variable, within set analysis $(=max(year)) has been used
This wont come into variable, just $<Year={}> with empty { } comes up. How to fix this?
In the above pic it is seen, vB has $<Year={ }> instead of $<Year={$(=max(Year))}>
Note: It is properly allocated in data model.
Oldie but goodie - the same solutions should still apply.
set $(vVar_name)="=replace('$(vVar_expression)','~','$')";
Just realized that this should work. Won't double the amount of variables.
Oldie but goodie - the same solutions should still apply.
Great! This method worked fine for me.
But it will just create double the amount of variables by using one variable just for replace function:
set $(vVar_name)="$(vVar_expression)";
set v$(vVar_name)final= "=replace([$(vVar_name)],'~','$')";
Is there any way to get around this? Just curious. Doubling the number of variable might effect performance. That is my concern.
set $(vVar_name)="=replace('$(vVar_expression)','~','$')";
Just realized that this should work. Won't double the amount of variables.