# New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Highlighted
Contributor II

## SET EVALUATE

hi,

I have specified Set x=3+4; in script and when i evaluate as =\$(x) in text box, it gives 7.Why is that so ?

1 Solution

Accepted Solutions
Highlighted

## Re: SET EVALUATE

The different engines involved act like that because of two simple reasons:

• text literal assignment (scripting engine), and
• text substitution (expression evaluator)

A SET statement assigns the right hand part as-is to the variable specified in the left hand part. So x will contain string '3+4'.

Now in the expression, the evaluator will perform \$-sign substitution first, before doing anything else. That gets the original expression =\$(x) converted into =3+4 after which the expression is finally evaluated and produces a fixed value of 7. That one gets displayed.

Note that what applies to the expression with respect to \$-sign substitution always coming first, also applies to the right-hand part of the SET statement. \$-sign substitution in the right-hand part of a SET statement will be applied even before the scripting engine tries to figure out what statement it is looking at. And that's the main reason why stuff like the following even works at all !

SET y = SET;

\$(y) x = 3+4;

Best,

Peter

4 Replies
Highlighted
Employee

## Re: SET EVALUATE

It seems to be correct to me, what do you see as wrong?

What do you expect to see?

Highlighted
Honored Contributor III

Highlighted

## Re: SET EVALUATE

Off course, Because you are computing using \$() indicator. Remove that and check with simple x ??

Set x=3+4; //vVar has the expression 2+3 as value we have to compute it using \$(vVar) which returns 5

Let x=3+4; //vVar has the computed value 5

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted

## Re: SET EVALUATE

The different engines involved act like that because of two simple reasons:

• text literal assignment (scripting engine), and
• text substitution (expression evaluator)

A SET statement assigns the right hand part as-is to the variable specified in the left hand part. So x will contain string '3+4'.

Now in the expression, the evaluator will perform \$-sign substitution first, before doing anything else. That gets the original expression =\$(x) converted into =3+4 after which the expression is finally evaluated and produces a fixed value of 7. That one gets displayed.

Note that what applies to the expression with respect to \$-sign substitution always coming first, also applies to the right-hand part of the SET statement. \$-sign substitution in the right-hand part of a SET statement will be applied even before the scripting engine tries to figure out what statement it is looking at. And that's the main reason why stuff like the following even works at all !

SET y = SET;

\$(y) x = 3+4;