Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

adamgaox
Contributor

Dollar sign expansion with variable issue with & operator in expression

Dear All,

I have an issue with dollar sign expansion with my variable;

I have set my variable2 as =MaxString(MTH) & 'Q'

When I use the variable2 in expression

=$(Variable2)  in textbox

it will return Garbage after expression 'Q'

but if I write ='$(Variable2)' it will work and show the correct value.

Could anybody explain me the reason?

I have attached my qvw file.

 

Thanks in advance.

1 Solution

Accepted Solutions
Partner
Partner

Re: Dollar sign expansion with variable issue with & operator in expression

Hi!

When you usea a variable with dollar expanssion there are several steps that you have to take into account:

  1. The variable is evaluated (if the variable definition starts with '='). Thus, the expresion =MaxString(MTH) & 'Q'  is evaluated. Let's suppose that the evaluation gives JaimeQ (where Jaime is MaxString(MTH))
  2. Expansion: the $(whatever) is substituted by its content. In this case, $(Variable2) is substituted by JaimeQ .
  3. Evaluation: the result of the expanssion is evaluated so QlikView is trying to interpret the expression "=JaimeQ" and it is, obviously, wrong.

Summarizing, when you write in a text box

=$(Variable2)

It is equivalent to

=JaimeQ

WRONG! On the other hand, when you write

='$(Variable2)'

it is equivalent to

='JaimeQ'

CORRECT! 

I hope I've explained myself!

Regards,

Jaime.

View solution in original post

3 Replies
anushree1
Valued Contributor II

Re: Dollar sign expansion with variable issue with & operator in expression

Its because qlikview needs to undestand that the value passed is a string so the quotes help in providing that information, hope that helps

Partner
Partner

Re: Dollar sign expansion with variable issue with & operator in expression

Hi!

When you usea a variable with dollar expanssion there are several steps that you have to take into account:

  1. The variable is evaluated (if the variable definition starts with '='). Thus, the expresion =MaxString(MTH) & 'Q'  is evaluated. Let's suppose that the evaluation gives JaimeQ (where Jaime is MaxString(MTH))
  2. Expansion: the $(whatever) is substituted by its content. In this case, $(Variable2) is substituted by JaimeQ .
  3. Evaluation: the result of the expanssion is evaluated so QlikView is trying to interpret the expression "=JaimeQ" and it is, obviously, wrong.

Summarizing, when you write in a text box

=$(Variable2)

It is equivalent to

=JaimeQ

WRONG! On the other hand, when you write

='$(Variable2)'

it is equivalent to

='JaimeQ'

CORRECT! 

I hope I've explained myself!

Regards,

Jaime.

View solution in original post

adamgaox
Contributor

Re: Dollar sign expansion with variable issue with & operator in expression

Thanks a ton.