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: 
Not applicable

Replace more than one Value

I have the following column:

Medium:

cpc

cpc

none

none

none

organic

email

I would like to do the following replacements within Medium field:  cpc --> PPC

                                                                                             none --> Direct

                                                                                         organic --> SEO

                                                                                            email --> Campaign

what function would be the best to use and how would the script look like?

Thanks,

7 Replies
MayilVahanan

Hi

Try like this

Whether use if condition

or

Mapping load * inline[

];

And then use ApplyMap, both helps

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

How would it look like with more than 2 if conditions?

Not applicable
Author

ApplyMap is the better option.

alexpanjhc
Specialist
Specialist

i agree applymap looks nicer

but there you go

if (Medium='cpc', 'PPC', if (Medium='none', 'Direct', If (Medium='organice', 'SEO', if (Medium ='email', 'Campaign', null())))) as new_field;

alexpanjhc
Specialist
Specialist

i agree applymap looks nicer

but there you go

if (Medium='cpc', 'PPC', if (Medium='none', 'Direct', If (Medium='organice', 'SEO', if (Medium ='email', 'Campaign', null())))) as new_field;

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

MediumMap:

MAPPING LOAD * INLINE [

cpc,  PPC

none, Direct

organic, SEO

email, Campaign

]

;

MAP Medium UISNG MeduimMap;

-Rob

CELAMBARASAN
Partner - Champion
Partner - Champion

If the Replacement texts are less then you can go with this option also

Pick(Match(Medium,'cpc','none', 'organice','email'),'PPC','Direct','SEO','Campaign') AS NewField