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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can I use an if in a "Select in field" Action on the field value?

I like to use an if statement in a button "select in field" action.

So in the field i now have:

if (pctypeid='2',pnTable,pcTable)

So depending on the value of pctypeid, I like to do a select/search on the pnTable or the pcTable.

The "Search String" of the action is a value I entered in a variable.

Thanks in advance.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

It's very simple, this is the script:

Data:

LOAD * INLINE [

Name, Address

AAA, AA-AAA

BBB, BB-BBB

AAA, BB-BBB

BBB, AA-AAA

];

Code:

LOAD * INLINE [

Code

1

2

3

4

];

And the button as an action that has Select in Field

=If(Even(Code), 'Address', 'Name')

And Search String

='*' & vSearchFor & '*'

If values 2 or 4 are selected in Code, the button will search for values starting with the value stored in the variable vSearchFor in the field Address, otherwise, search the same string but in the field Name. Two considerations worth mentioning:

  1. Obviously, this can be refined as much as you want, using a conditional in the search string as well
  2. Obviously, if the field where you are doing selections is in a table linked to the rest of the data model, the button may have no effect, since QlikView selects all possible values regardless where the selection is made.

Hope that helps.

Miguel

View solution in original post

6 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, Stormy,

of course you can use an if-.statement, it must begin with "=":

=if (pctypeid='2',pnTable,pcTable)

Greetings from Munich

Martina

EVACO GmbH

Miguel_Angel_Baeyens

Hi,

Indeed, any time you see the [...] button at the side of a text dialog means that it allows expressions. Check the attached application.

Hope that helps.

Miguel

Not applicable
Author

I have tried that, but does not seem to work.

This is how it now looks.

It just does not do a sub select.

Capture.JPG

Not applicable
Author

I cannot open your example, as I am still using the personal edition. (My work is still in discusion to buy a developer version)

Miguel_Angel_Baeyens

Hi,

It's very simple, this is the script:

Data:

LOAD * INLINE [

Name, Address

AAA, AA-AAA

BBB, BB-BBB

AAA, BB-BBB

BBB, AA-AAA

];

Code:

LOAD * INLINE [

Code

1

2

3

4

];

And the button as an action that has Select in Field

=If(Even(Code), 'Address', 'Name')

And Search String

='*' & vSearchFor & '*'

If values 2 or 4 are selected in Code, the button will search for values starting with the value stored in the variable vSearchFor in the field Address, otherwise, search the same string but in the field Name. Two considerations worth mentioning:

  1. Obviously, this can be refined as much as you want, using a conditional in the search string as well
  2. Obviously, if the field where you are doing selections is in a table linked to the rest of the data model, the button may have no effect, since QlikView selects all possible values regardless where the selection is made.

Hope that helps.

Miguel

Not applicable
Author

Thanks, I had the table/field not in quotes.