Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

condition inside expression

Hello Qlik Community,

What is the most efficient - speed wise - way of doing row level conditions in expressions in a chart?

The only way I know of currently is to have the condition inside an if statement in the expression. 

i.e.:

if(count(stuff)<10,'',

(

( sum(other_stuff) / count(even_more_stuff) ) * count(never_ending_stuff)

)

)

As I understand it, the if will calculate all conditions before presentation - so storing in a variable is something I have been testing, but not seeing huge performance gains.

Thanks,

Tyler

5 Replies
Not applicable
Author

Hi!

I think, there is no way to avoid calculations of unused branches of IF or PICK - these parameters fully calculate at moment of function call, before main condition selection. And placing a part of expression in a variable is not helps.

But, if you have no dimensions (for example, in text box), you can use $-expanding for text of expressions (instead on expressions itself). So, after expanding only one text of IF executes:

=$(=If(True(), '2+2', '3+3'))       // In this example, expression '3+3' never evaluates.

But $-expanding is not dynamic and is calculated in chart only once. So, if you have any dimension, the IF condition is calculated only once, not for each dimension value (like TOTAL clause works).

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

Hi,

Try this expression

= sum({<other_stuff={'=count(stuff)>=10'}>}other_stuff) / count({<even_more_stuff={'=count(stuff)>=10'}>}even_more_stuff) ) * count({<never_ending_stuff={'=count(stuff)>=10'}>}never_ending_stuff)

Regards,

Jagan.

Not applicable
Author

Thanks for the reply, I am having an interesting result with this approach.  Within the pivot chart every record takes the value of the what would be correct for only the first record for the column with the condition applied.

rwunderlich

I think Andrei pointed out that you can't use the =$() technique if you have chart dimensions. If you did use that technique, getting the same value on every row would be expected.

To answer your initial question, I don't think there is anything more efficient than if() for doing row level conditions.

-Rob

Not applicable
Author

ah, thanks Rob