Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
williamyuen96
Contributor
Contributor

Replace Multiple Values

Let say I have multiple field values I need to replace, what would be the best option?

For example 
Ali, Bob, Abu

I want to change 
Ali to firstperson
Bob to secondperson
Abu to thirdperson

What the best possible way? I'm aware that REPLACE function would do the job but apparently I not sure if it able to handle multiple replace function. Or should I be using IF function to handle multiple replacing values?

3 Replies
Quy_Nguyen
Specialist
Specialist

Hi,

If Ali, Bob, Abu... is the whole content of the field. I think ApplyMap function could help in the script. 

https://help.qlik.com/en-US/qlikview/November2018/Subsystems/Client/Content/QV_QlikView/Scripting/Ma...

If you want to do it from chart expression, try this:

 

Pick(Match([Name], 'Ali', 'Bob', 'Abu'),
 'FirstPerson',
 'SecondPerson',
 'ThirdPerson')

 

williamyuen96
Contributor
Contributor
Author

Aside from APPLYMAP function, is IF function much suitable to tackle REPLACE function for this type of scenario?

Quy_Nguyen
Specialist
Specialist

You can use IF or Pick-Match which I proposed above. But for me I prefer Pick-Match rather than IF for its readability when you have a complex condition.