Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I am using if nested, but I am having performance problems. I would like to know how does qlikview evaluate the conditions. I mean, if the first condition is true then the other "if" conditions are not evaluated? or do all "if" conditions are evaluated always?
For example:
if(a=b,1,if(a=c,if(a=d,1,0)))
desired behaviour:
If a=b -> True, then qlikview returns 1 and ignores the other "if" statements. Is this the real behaviour?
Please help me to understand!
Thank you.
Linda
Hi,
Another possible solution is if possible move all complex expression in script.
Create flag according to that and use flag in expression.
Regards,
I agree that some refactoring of your model and/or performing the calculations in the back end are the best solution. But in the meantime, you could try restating the expression:
=If(RangeMax(a, b, c, d, ...., n) > 0, 1, 0)
Just fill in the RangeMax with all the values that you want to test for > 0. It may perform better than the if expression.
Hi Marcus,
a, b, c.. are expressions like this:
if(isnull($(vLI($1,'P027','E050'))) and isnull($(vLS($1,'P027','E050'))),0,
if(isnull($(vLI($1,'P027','E050'))),if($(vValor($1,'P027','E050')) <= $(vLS($1,'P027','E050')),0,1),
if(isnull($(vLS($1,'P027','E050'))),if($(vValor($1,'P027','E050')) >= $(vLI($1,'P027','E050')),0,1),
if($(vValor($1,'P027','E050')) >= $(vLI($1,'P027','E050')) and $(vValor($1,'P027','E050')) <= $(vLS($1,'P027','E050')),0,1))))
$vLI, $vLS and $vValor are variables that return me values from the data using set analysis and taking into account the parameters that I send to them.
$vLI -> returns me the limit inferior of the year that the user has selected in the filter.
$vLS -> returns me the limit superior of the year that the user has selected in the filter.
$vValor -> returns me the value that I want to compare with limits.
Functionality: I compare if a value is out from limits superior and inferior. If it is out, returns "1", if not returns "0".
The problem is that I need to compare 500 values. If at least one of them is out from limits my object (indicator) has to be painted red.
$variable code:
if(
a>0 or
b>0 or
c>0 or
...(500 comparisons more)
z>0 ,1,0)
indicator expression:
if($variable>0,1,0)
And it has to be dynamic, I mean, if the user select a date filter, the calculations have to be done at the moment, that's why I don't think I can put it within the script.
Another alternative that I have tested is to distribute the calculations in more than one indicator, it is faster but the problem is that too many objects on the sheet is still a performance problem.
That is the complete scenario. Hope you have any idea to improve the performance. Thank you!
Thank you Jonathan, I will test it.
Hi Max,
Thank you, as I explain to Marcus above, I don't think I can put the code within the script because it has to be dynamic, depending on a date filter that the user selects on the gui.
Hi Jonathan,
I have tested with RangeMax but it takes the same time to be calculated
I have the feeling that your approach is somehow overcomplicated and that it could be simplified in any way. Please provide a small example:
Preparing examples for Upload - Reduction and Data Scrambling
- Marcus