Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to set a variable (FC) either to be a factor ("*1.3") or a summand ("+0.3"). This variable shall then be used as a function on the field "price":
eval('price'&FC)
In Matlab this would work. or in excel it would be:
indirect('price'&FC)
But how can I do this in QlikView?
Best,
Joans
Thank you Bapperson! Looks good, but as you metnion, the variable is used in an expression and is dynamically alteredd by the user, so the scripted solution won't work. :-S
My way around the problem:
I just defined two variables: FC_factor and FC_summand, so that I defined the expression as
price*FC_factor+FC_summand
Although this did not solve the original question it provided a solution by circumventing the problem.
Apparently the evaluate function in QlikView only works at the script level.
In the script as an example I did:
Table1:
LOAD * INLINE
[
Price
100
200
300
400
500
];
set FC = "*1.3";
set FC2 = "+0.3";
Table2:
LOAD *,
Evaluate(Price $(FC)) as FCPriceCalculated,
Evaluate(Price $(FC2)) as FC2PriceCalculated
Resident Table1;
Drop table Table1;
This calculates based on your variables into the new fields.
If you try and use evaluate at the expression level or in a variable it will not work... 😕
I have attached a working qvw for your reference as well.
Hope this helps!
Thank you Bapperson! Looks good, but as you metnion, the variable is used in an expression and is dynamically alteredd by the user, so the scripted solution won't work. :-S
My way around the problem:
I just defined two variables: FC_factor and FC_summand, so that I defined the expression as
price*FC_factor+FC_summand
Although this did not solve the original question it provided a solution by circumventing the problem.