Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ValeriaBonini
Partner - Creator
Partner - Creator

mapping table

I have a LOAD script with many columns.

I have to check if one of them (COLUMN3) contains the word "cat", and then I have to create a new column with the value "yes" if COLUMN3 contain "cat", "no" if COLUMN3 doesn't contain "cat".

How can I do that with a mapping table? 

Labels (5)
6 Replies
deepanshuSh
Creator III
Creator III

Hi @ValeriaBonini it can be easily done using the if and else condition on the respective column, for instance 

if (Column3 ='cat', yes, no) as New_column3

 

use single quotes and normal if condition if you want to do a simple match and wildmatch if you want to use the case insensitive version for multiple characters. 

Trial and error is the key to get unexpected results.
MarcoWedel

Why are you referring to a mapping table, are there other searchstrings than just 'cat'?

RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @ValeriaBonini 

im not sure why you mention “mapping table”

but, you can try this in script

 

 If “cat” can be in any place of the field value

if (wilmatch(Column3,'*cat*'),' yes', 'no') as New_column3

 

if have to start with “cat”

if (wilmatch(Column3,'cat*'),' yes', 'no') as New_column3

or

if (left(Column3,3)='cat'),' yes', 'no') as New_column3

 

Hope this works for you

best,

ValeriaBonini
Partner - Creator
Partner - Creator
Author

Hi, yes I have many strings to check (5) 

ValeriaBonini
Partner - Creator
Partner - Creator
Author

I have many strings to check

MayilVahanan

Hi 

Try like below

MapTable1:

Mapping Load *, 'Yes' as Value2 inline

[

Value1

Cat,

Dog

];

 

Load *, ApplyMap('MapTable1', COLUMN3 , 'No') as COLUMNNew from ursource;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.