Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I had a question recently, but I have almost figured out the solution.
It's about the following I have a system variable that I define as a function. If I now call the function with a small sum function and Set Analysis it works for 3 of 4 cases.
I am interested in the case that does not work. The function contains a system variable defined on the surface.
$(vFunc(
sum({<Expression1={"$(=$(v61))"}, Expression2={'0'}, Expression2={'1'}>}Expression1)
))
and vFunc is only $1
which should only read the input.
Does anyone know how to cover the fourth case like this? This is a trivial example, which will be used later for practical purposes.
The issue seems to be that Qlik interprets the comma "," between your set analysis criteria as addition parameters that are being passed to the vFunc variable ($2, $3, etc.).
One way to solve, is to use ';' instead of comma in the expression to pass it as a parameter and then replace ';' with ',' in the vFunc; Not sure if this is the best approach, but it works.
vFunc = $(=Replace($1,';',','))
The expression:
$(vFunc(
'sum({<Expression1={"$(v61)"}; Expression2={0}; Expression2={1}>} Expression1)'
))
Note that I got rid of the single quotes around the Expression2 criteria. If you must include quotes, use 2 single quotes around the values because it is inside a string.
Why is Expression2 included twice in your set analysis? I believe only the second will apply.
Hope this helps.
It doesn't work because your parameter contains a comma which will be always treated as a parameter-delimiter from the variable. There is no way to mask it else you would need any workarounds which don't contain commas and/or the commas are replaced with any other char and later the approach is reversed again.
I don't want to say that's not possible to nest variables but I wouldn't recommend any trial of it because it's the opposite to the main-aim of variables which is to simplify things.
- Marcus
The issue seems to be that Qlik interprets the comma "," between your set analysis criteria as addition parameters that are being passed to the vFunc variable ($2, $3, etc.).
One way to solve, is to use ';' instead of comma in the expression to pass it as a parameter and then replace ';' with ',' in the vFunc; Not sure if this is the best approach, but it works.
vFunc = $(=Replace($1,';',','))
The expression:
$(vFunc(
'sum({<Expression1={"$(v61)"}; Expression2={0}; Expression2={1}>} Expression1)'
))
Note that I got rid of the single quotes around the Expression2 criteria. If you must include quotes, use 2 single quotes around the values because it is inside a string.
Why is Expression2 included twice in your set analysis? I believe only the second will apply.
Hope this helps.
Thanks you ! This helps me !
Hello thank you for your solution,
when I work with this approach I make good progress, but there is one limitation I noticed, when I work with conditions e.g. buttons it does not recognize the "". This does not work in the normal case. I have already tried to replace ' but without success. Would you perhaps also have a solution suggestion?
This doenst work
Not sure if this is causing your issue, but are you missing a ) at the end of that expression?
$(vFunction('if(vButton="ButtonA";1;2)'))
Unfortunately no, I forgot the bracket probably from hectic thanks for the tip. I think it is because of 'ButtonA' which was written as "ButtonA". But i have no idea how to solve it.
Try using 2 single quotes on each side of ButtonA instead of double quotes. Like this:
$(vFunc('if(vButton=''ButtonA'';1;2)'))
This worked for me when vButton is define as ButtonA in the variable definition panel.