Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ManojMJ
Partner - Contributor
Partner - Contributor

How to write Else part in Pick & Match function and why Pick & Match is better than Nested if statement

How to write Else part in Pick & Match function and why Pick & Match is better than Nested if statement?

Labels (1)
5 Replies
Vegar
MVP
MVP

Using pick'n match will be faster as it will only evaluate your match expression once, in nestled if statements it will be evaluated once per if statement.

It is can also be a more condense way of writing your code. It is also easier to increase / decrease the values to compare .

 

As a no match pick() will retun zero, I often add a +1 to my pick() in order to get a default value.

Pick(1+match(...),'default value', 'value1','value2',...)

ali_hijazi
Partner - Master II
Partner - Master II

I use the following technique:
pick(WildMatch('$(vAppStreamName)','unpublished','*test*') + 1, your_else_part, value1, value2)

I can walk on water when it freezes
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

@Vegar 

"Using pick'n match will be faster as it will only evaluate your match expression once, in nestled if statements it will be evaluated once per if statement."

I disagree. Last time I tested, every pick() option is evaluated, just as every branch of an if() is evaluated. Did something change or do you have experience to the contrary?

-Rob

Vegar
MVP
MVP

@rwunderlich 

This has been my believed known truth for years, so I have not questioned it. 

Based on what you are writing here I will withdraw my statement of pick and match being faster, I do however in most cases find it faster to write script using that technique;-) 

I interpret your comment as you have found the two to be about equal in term of reload performance. Is that a correct understanding?

Thanks for remarking on my comment.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

@Vegar I have not tested performance in a reload script. I have however tested in a chart (confirmed yesterday). I've found the performance to be identical.

-Rob