Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

List box Expression

Hi

I want to give a list box expression: If the values of age are 30 and 50, then show age.

It works when I write this expression : =if([Age]='30', Age)

How do I also include the value 50?

It throws an error when I try to write the expression :  if([Age]={'30', '50'}, Age)

Thanks

10 Replies
aveeeeeee7en
Specialist III
Specialist III

Hi

Use this Expression:

if(Match([Age],'30','50'), Age)

Regards
Av7eN

maxgro
MVP
MVP

you can also use an or

=if(Age=30 or Age=50, Age)

Anonymous
Not applicable
Author

Hey,

This expression is not working.

Anonymous
Not applicable
Author

Thank You!

maxgro
MVP
MVP

why not?

1.png

jagan
Luminary Alumni
Luminary Alumni

Hi,


Try like this


If(Match(Age, 30, 50), Age)


OR


If(Age = 30 OR Age = 50, Age)


The preferred method is using Match(), if you have more values then the length If() expression will become more.  So best use Match().


Regards,

Jagan.



Anonymous
Not applicable
Author

Hi,

I have loaded  thousand of records using Load script. I created a List Box and it shows all the thousand distinct values as below screen

LEGETYNACE-LISTBOX.PNG

Now i want filter and display only 6511001,6511002,7511001 and 7511006.

I went  properties of list box and wrote the expression  as below

ListBox-Expression.PNG

I see the matching values besides the value and rest all not matched has '-'. I want to see only match values in the list box.

Please see below the values i see as :

Listbox-Output.PNG

I want to see only Matching value and rest all should be hidden.

Appreciate your help.

Regards,

Paul

Not applicable
Author

You can create LB Expression on drop down of your fields list. You can see <Expression> final field in the list.

jagan
Luminary Alumni
Luminary Alumni

Hi Paul,

YOu need to write this expression in

Properties -> General-> Field -> Select <Expression> -> and give your expression there.

OR the best method is in script arrive a new column like below

LOAD

*,

If(Match(FieldName), Num1, Num2, Num3), FieldName) AS NewFieldName

FROM Datasource;

Hope this helps you.

Regards,

jagan.