Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Find and Replace Multiple Characters

I have a field where I want to find and replace a multiple letters within the data of a field.  See example below.

11111A

11111B

11111C

I need to replace A, B and C.  A should be replaced with 1, B with 2 and C with 3 when present.  I know if I just had one character, I could just use the REPLACE function.  But in this case I have multiple different characters that could be found within the field.  How do I go about search and replacing multiple characters with the data of a field. Hopefully, that makes sense.

Thank you in advanced for your assistance.

Brian

3 Replies

Re: Find and Replace Multiple Characters

Could you nest the Replace() 's :

=replace ( replace ( replace ( '11111A' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

=replace ( replace ( replace ( '11111B' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

=replace ( replace ( replace ( '11111C' ,'A' ,'1' ) , 'B' , 2 ) , 'C' , '3' )

Re: Find and Replace Multiple Characters

Maybe you could use mapsubstring.

Regards

Marco

MVP
MVP

Re: Find and Replace Multiple Characters

Map:

mapping load * inline [

from, to

A,1

B,2

C,3

];

MyTable:

load field, MapSubString('Map', field) as newfield inline [

field

11111A

11111B

11111C

ABC

];

Community Browser