Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Extract Text from value within a varriable

Hi Guys,

I have a variable that looks like below:

var1=Sum(Sales) /*Sales Amount*/

The variable is generated by the script and i would like to extract the value within /**/ which is "Sales Amount"

Let me know your thoughts..

Thxs,

Badr

1 Solution

Accepted Solutions
pgrenier
Partner - Creator III
Partner - Creator III

Hello Badr,

It is the presence of the ' character that creates the problem. You can eliminate them from the equation using the PurgeChar() function:

var1=TextBetween(PurgeChar(var1, Chr(27)), '/*', '*/')

Regards,

Philippe

View solution in original post

7 Replies
MK_QSL
MVP
MVP

This is Multiline comment and once your run the script, you will lose them.

pgrenier
Partner - Creator III
Partner - Creator III

Hello Badr,

You could use the TextBetween() function as such:

=TextBetween('$(var1)', '/*', '*/')

Regards,

Philippe

preminqlik
Specialist II
Specialist II

hi there

you have to write in script like below

set vVar1='sum(Sales)/*sum amount */'

and in frontend or backend

=TextBetween('$(vVar1)', '/*', '*/')


or


replace(subfield('$(vVar1)',/*',2),'*/',null())

alec1982
Specialist II
Specialist II
Author

TextBetween works but if the variable has Num()around it it doesn't..

var1= Num(sum(Sales),'#,##0')/*Sales Amount*/

alec1982
Specialist II
Specialist II
Author

Not sure about the replace statement but it seems to be wrong.. Textbetween works but the issue if the variable has Num() function around the expression then it doesn't work.

pgrenier
Partner - Creator III
Partner - Creator III

Hello Badr,

It is the presence of the ' character that creates the problem. You can eliminate them from the equation using the PurgeChar() function:

var1=TextBetween(PurgeChar(var1, Chr(27)), '/*', '*/')

Regards,

Philippe

alec1982
Specialist II
Specialist II
Author

Thxs so much!