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: 
ivandrago
Creator II
Creator II

IF In List Statement

Hi,

I want to add a flag and set this to 1 if the name is equal to Trev or Ross, I have tried the following script but QlikVIew does not like it?

If(Name in ('Trev','Ross'),1,0) as Flag

Thanks

Ivan





6 Replies
hector
Specialist
Specialist

Hi, use match instead

If(match(Name,'Trev','Ross'),1,0) as Flag

Rgds

ivandrago
Creator II
Creator II
Author

Nice Work Hector

Shax
Contributor
Contributor

how to write multiple names in "Name"?

 

sidhiq91
Specialist II
Specialist II

@Shax how many names are we talking about? If it is way too high, we can get the desired output using Mapping Load and Applymap concept. Something like below:

Mappingtable:

 

Mapping load 

Name

Value

From Table_Name:

MainTable:

Load Name,

Applymap('Mappingtable',Name,'Unknown') as Flag

From Table_Name;

marcus_sommer

You may try: 

If(wildmatch(Name1 & '|' & Name2,'*Trev*','*Ross*'),1,0) as Flag

But you will need to specify all relevant name-fields directly and also using wildmatch() by applying wildcards to your search-strings which may result in some overlapping.

Alternatives could be to nest multiple match() logic or to transform your crosstable-structures with a crosstable-statement into a stream-data-structure - means it remains only one name-field and the multiple values are distributed to records.

- Marcus

Nakosan
Contributor II
Contributor II

What about multiple conditions in the same measure/column? 

Like this;

If(match(nativeCode, 1, 2, 3, ),'Minor severity')

If(match(nativeCode, 4, 5, 6, ),'Medium severity')

If(match(nativeCode, 7, 8, 9, ),'Critical')