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: 
vignesh_s
Creator
Creator

replace string

hi all i have 2 excel file,1st 1 is String and 2nd excel contains which string should replaced with what

ex:

  excel1:

Name
My name is Fund
A for Apple
Apple is a fruit
C for Cat
Fund is a Vlaue
D for Dog
F for Fund
E for Eli
Xmas is on 25 dec

excel2:

StringReplace String
ballBat is best because of batman
dog is not
eliVadivel padam
appleAndroid is best
xmaspongal tha gethu

i need scrit such that it should work dynamicaly,means what ever i give in 2nd excel (replace string) should reflect in out put by just doing reload.Can any1 help

1 Solution

Accepted Solutions
sunny_talwar

I would not recommend using this, but here you go...

excel1:

LOAD * INLINE [

    Name

    My name is Fund

    A for Apple

    Apple is a fruit

    C for Cat

    Fund is a Vlaue

    D for Dog

    F for Fund

    E for Eli

    Xmas is on 25 dec

];


Temp:

NoConcatenate

LOAD *

Resident excel1;


Join (Temp)

LOAD Capitalize(String) as String,

[Replace String]

INLINE [

    String, Replace String

    ball, Bat is best because of batman

    dog, is not

    eli, Vadivel padam

    apple, Android is best

    xmas, pongal tha gethu

];


FinalTable:

LOAD Name,

Name as TempName,

[Replace String]

Resident Temp

Where WildMatch(Name, '*'&String&'*');


Concatenate(FinalTable)

LOAD Name

Resident excel1

Where Not Exists(TempName, Name);


DROP Table excel1, Temp;

View solution in original post

30 Replies
sunny_talwar

tresesco
MVP
MVP

Try like:

excel2:

Mapping Load Capitalize(String),

       [Replace String]

Inline [

String, "Replace String"

ball, Bat is best because of batman

dog, is not

eli, Vadivel padam

apple, Android is best

xmas, pongal tha gethu];

excel1:

Load *,

       MapSubString('excel2', Name) as StringAfterReplace Inline [

Name

My name is Fund

A for Apple

Apple is a fruit

C for Cat

Fund is a Vlaue

D for Dog

F for Fund

E for Eli

Xmas is on 25 dec];

Capture.JPG

vignesh_s
Creator
Creator
Author

can u share your qvd

vignesh_s
Creator
Creator
Author

hi,i wanna replace entier string with replacing string

sunny_talwar

May be this

excel2:

Mapping

LOAD Capitalize(String),

'/' & [Replace String] & '\'

INLINE [

    String, Replace String

    ball, Bat is best because of batman

    dog, is not

    eli, Vadivel padam

    apple, Android is best

    xmas, pongal tha gethu

];


excel1:

LOAD *,

TextBetween(MapSubString('excel2', Name), '/', '\') as StringAfterReplace

INLINE [

    Name

    My name is Fund

    A for Apple

    Apple is a fruit

    C for Cat

    Fund is a Vlaue

    D for Dog

    F for Fund

    E for Eli

    Xmas is on 25 dec

];

vignesh_s
Creator
Creator
Author

thank you,

if the string is not matched i wanna retain the same string,the above code giving blank for that

sunny_talwar

How difficult could that be for you to solve

If(Len(Trim(TextBetween(MapSubString('excel2', Name), '/', '\'))) = 0, Name, TextBetween(MapSubString('excel2', Name), '/', '\'))

Checking if the mapping gives 0 using len(Trim()) = 0... if it does, then just use Name, else use the mapping

tresesco
MVP
MVP

Try just putting an additional condition on substringmap() like:

....

If(MapSubString('excel2', Name)=Name, Name,

  TextBetween(MapSubString('excel2', Name), '/', '\')) as StringAfterReplace

....

vignesh_s
Creator
Creator
Author

hi sunny ,sorry to open this token again, i have some issue in this expression,i.e, you have used "delimiters" for replace strings and u retrived those from textbetween,but the issue is what if the input string or replace string contains delimiters already