Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
mukesh19
Contributor II
Contributor II

If Statement inside the Pick Function

Hi All,

I tried using if statement inside the pick function but, fail to achieve it. My question is it possible to achieve the scenario.

Eg: =$(=pick(vtest,'var1',if(condition1,var2,var3)))

when I stored the if statement in variable its working fine. I have multiple statements storing each and every condition takes lot of time. Could anyone help to find the alternative solution. 

Regards,

Mukesh

5 Replies
sunny_talwar

What exactly are var1, var2, and var3? Would you be able to share a sample where you can show the issue?
mukesh19
Contributor II
Contributor II
Author

Hi Sunny,
Thanks for the quick reply.
Vtest is the variable used for the button selection. values are assigned to the vtest as 1,2,3 etc.
Previously I used the expression like:
If(vtest=1,col1,
if(vtest=2, if(col2='A' or col2='B',col3))) and soo on based on number of button.

To optimize the nested if I tried to use the pick function as
=$(=pick(vtest,'col1',if(col2='A' or col2='B',col3))) but, if data is not getting displayed. when the condition is passed in variable its working fine
=$(=pick(vtest,'col1',vif)) where vif= if(col2='A' or col2='B',col3).

I would like to find the solution with out using variable


sunny_talwar

May be you need this

=$(=pick(vtest,'col1', $(vif)))
mukesh19
Contributor II
Contributor II
Author

using variable (vif) is working fine. I want to obtain the result with out using variable
sunny_talwar

I am a little confused here...

1) What is Col1 and Col2 and Col3? They are fields? Based on your if/pick condition, you want to get a particular field?

2) If 1) is true, then why is Col1 within single quotes and Col3 isn't?

=$(=pick(vtest,'col1',if(col2='A' or col2='B',col3)))

do you may be want col3 to be within single quotes also?

=$(=pick(vtest,'col1',if(col2='A' or col2='B','col3')))

This are things which can be easily seen through a sample. Right now all we know or see is what you are providing in your posts. Do you think you can post a sample so that we can see what you might have and what you need to get this fixed?