Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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,
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
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
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.