Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
satishqlik
Creator II
Creator II

suggest

Hi Community,

I have a string 01#345@78$

How to change the special characters (#,@,$) to 2,6,9 respectvely from the string?

I tried with using replace function but didn't work properly

Any ideas?

1 Solution

Accepted Solutions
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

map1:

mapping load * inline [

     #, 2

     @, 6

     $,9

] ;

Data:

LOAD *,

MapSubstring ('map1', F1) as new

INLINE [

    F1

    01#345@78$

];

Result:

Screenshot_2.jpg

See the attachement.

View solution in original post

9 Replies
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

You can use Replace or MapSubstring functions.

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

=replace(replace(Replace('01#345@78$', '#', 2), '@', 6), '$', 9)

Well Replace works fine.

Result:

Screenshot_1.jpg

satishqlik
Creator II
Creator II
Author

Thanks but how can we do by using MapSubstring function?

It showing only two parameters map_id and text.

sunny_talwar

May be like this:

MappingTable:

Mapping

LOAD * Inline [

From, To

#, 2

@, 6

$, 9

];

FactTable:

LOAD FieldName,

          MapSubString('MappingTable', FieldName) as NewFieldName

FROM Source;

tamilarasu
Champion
Champion

Hi Satish,

Hope you are asking for dynamic expression. If so, try below expression,

=Replace(

    Replace(

       Replace('01#345@78$',

                '#',Mid('01#345@78$',Index('01#345@78$','#')-1,1)+1),

             '@',Mid('01#345@78$',Index('01#345@78$','@')-1,1)+1),

          '$',Mid('01#345@78$',Index('01#345@78$','$')-1,1)+1)

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

map1:

mapping load * inline [

     #, 2

     @, 6

     $,9

] ;

Data:

LOAD *,

MapSubstring ('map1', F1) as new

INLINE [

    F1

    01#345@78$

];

Result:

Screenshot_2.jpg

See the attachement.

qlikview979
Specialist
Specialist

Hi Satish,

You can try this

Untitled...png

satishqlik
Creator II
Creator II
Author

Thanks for all your ideas...

Saravanan_Desingh

One more version..

Load  Concat(Out,'') As text2;

Load *,

Alt(Mid(text,IterNo(),1)*1,IterNo()-1) As Out

Inline [

text

01#345@78$

]

While IterNo() <= Len(text);

text2 will have 0123456789