Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
has75042
Creator
Creator

If Statement

Is there a better way of categorizing the below if statement

IF(Dept = 86 or Dept = 87 or Dept = 90, 'Fiction',
IF(Dept = 41 or Dept = 42 or Dept = 43 or Dept = 44 or Dept = 45 or Dept = 46 or Dept = 47 or Dept = 48 or Dept = 49 or Dept = 50 or Dept = 51 or Dept = 52 , 'Non-Retail Supply',
IF(Dept = 91 or Dept = 92, 'Used-Fiction',
IF(Dept = 60 or Dept = 90, '60/90', 'Not-Book')))) as DType,

1 Solution

Accepted Solutions
Anonymous
Not applicable

you may use match, makes it easier to read

if (match(Dept,86,87,90)>0, 'Fiction',

 if (match(Dept, 41, 42, .....

   if (match (Dept. 91,92 ...

 ..... as DType

View solution in original post

2 Replies
Anonymous
Not applicable

you may use match, makes it easier to read

if (match(Dept,86,87,90)>0, 'Fiction',

 if (match(Dept, 41, 42, .....

   if (match (Dept. 91,92 ...

 ..... as DType

Colin-Albert

Use a match() or wildmatch() statement  or consider using applymap()

if(match(Dept, 86, 87, 90), 'Fiction',
if(wildmatch(Dept, '4?', 50, 51, 52), 'Non-Retail Supply',
etc
'Not-Book')) as DType

 

For applymap have a look at this blog
     https://community.qlik.com/t5/Qlik-Design-Blog/Don-t-join-use-Applymap-instead/ba-p/1467592

I would use a mapping table and applymap myself, as addition values can be added to the mapping table without the need to amend the load script, as the mapping table data can be loaded from a datasource, or file.