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

How to evaluate value in variable

I need help  getting the output table below from my script. 

Load * Inline[Text

text1

text2

text3

Text4

];  

 

Let text1= cadeau;

Let text2= 20;

Let text3= 1;

Let Text4= $(text2)+$(text3);

 

Table settings

Dimension

Text

 

Measure

'='&'''$'&'('&Text&')'''

 

This is not returning the values on the table. How to display the values on the measure column?

 Thanks

 

 

1 Solution

Accepted Solutions
MayilVahanan

HI 

Try like below

Let text1= 'cadeau';

Let text2= 20;

Let text3= 1;

Let Text4= $(text2)+$(text3);

Load *, evaluate(Text) as M Inline [
Text
text1
text2
text3
Text4

];

O/p:

MayilVahanan_0-1628384092408.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

5 Replies
MayilVahanan

HI 

Try like below

Let text1= 'cadeau';

Let text2= 20;

Let text3= 1;

Let Text4= $(text2)+$(text3);

Load *, evaluate(Text) as M Inline [
Text
text1
text2
text3
Text4

];

O/p:

MayilVahanan_0-1628384092408.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
ericdelaqua
Creator
Creator
Author

Hi @MayilVahanan 

Your suggestion worked when I tried but when I applied to the actual data it didn't quite work. the different is that I am actually Auto generating the variables from a qvd. Please see the actual code below.

This worked:

Let text1= 'cadeau';

Let text2= 20;

Let text3= 2;

Let Text4= ($(text2)+$(text3))*$(text3);
Let Text5= '$(text2)';
Let Text6= If('$(text1)'='cadeau',$(text3),100);

Load *, evaluate(Text) as M Inline [
Text
text1
text2
text3
Text4
Text5
Text6
];

 

CODE NOT WORKING

Sub LoadVariables


Variables:
LOAD
"Text",
M
FROM [lib://DataFiles/VarData.qvd]
(qvd);


LET Table =;

//Let Variables
CALL Qvc.PopulateVariables('Variables');

DROP Table Variables;
ENDSUB

SUB Qvc.Populatevariables(vVarTableName)

For i=0 to NoOfRows(vVarTableName)
Let vVarFieldName = FieldName(1, '$(vVarTableName)');
Let vVarValueFieldName = FieldName(2, '$(vVarTableName)');
Let vVariableName = Peek('$(vVarFieldName)', $(i), '$(vVarTableName)');
Let $(vVariableName) = Peek('$(vVarValueFieldName)', $(i), '$(vVarTableName)');
Next

End SUB

Call LoadVariables;

Load *, evaluate(Text) as M Inline [
Text
text1
text2
text3
Text4
Text5
Text6
];

 

 

Output

datasp.png

MayilVahanan

Hi @ericdelaqua 

Might be, its due to field name is in Capitalize , but variable is in lower cast

MayilVahanan_0-1628405570086.png

 

Can you try with lower case and verify it

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
ericdelaqua
Creator
Creator
Author

@MayilVahanan 

 

yes that was part of the issue but the variable are still not fully evaluating, I think it is just evaluating the Text values.

Pleasee see below.

variables.png

 

really appreciate your assistance.

thanks

ericdelaqua
Creator
Creator
Author

ok I have changed the query to this and it is working except for TEXT.

Load *, Evaluate(evaluate(Text)) as M Inline [
Text
text1
text2
text3
text4
text5
text6
];

variables.png