Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
vajid4525
Contributor III
Contributor III

pick and if function

Hi Team,

I came to know about the pick function in Qlik.

pick( N,'A','B',4, , , )

returns 'B' if N = 2

returns 4 if N = 3

the same thing I can get by using if function

(if N==1,'A',(if N==2,'B',(if N==3,4)))

Whether the pick function is more optimized way compared to the if function, as the pick function, picks the value in the index mentioned using N? In the case of if function, the worst case needs to check all if conditions mentioned in the chart expression? Please let me know whether my understanding is right or not.

Thank you

Labels (1)
1 Reply
Chanty4u
MVP
MVP

Right .

Yes, your understanding is correct. The pick() function in Qlik is generally more optimized compared to using nested if() functions in terms of performance and readability of the expression.

 

Using pick() function, Qlik can directly access the value at the specified index based on the value of N, while in the case of nested if() functions, Qlik has to check all the if conditions until it finds a match.

 

Therefore, if you have a large number of if conditions or if the conditions are complex, it's generally better to use the pick() function to improve the performance of your Qlik script.