Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

LET and SET

Hi

What is the use of LET and SET? What is the difference between them?

Thanks

Attitude

9 Replies
Miguel_Angel_Baeyens

Hi,

As you can see in the Reference Manual, they are used to assign values to variables in the load script. The main difference is that while SET assigns the value to the variable without evaluation, as a string, the LET first evaluates the expression at the right part of the "=" sign, then stores the value.

Two simple examples:

SET vLiteral = 1 + 1; // This stores the string "1 + 1";

LET vSum = 1 + 1; // This stores 2

Check for further reference the Manual and this thread on how they work and when and how to expand and this other one among many others.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

its_anandrjs

Hi,

The Set command assigns the variable the text to the right of the equal sign, whereas the Let command evaluates the expression

set variablename = string

let variable = expression

Rgds

Anand

Not applicable
Author

Hi,

Let and Set commands are used to define Script Variables. Any text or numeric value can be assigned to the script variables.

Examples:

                  1.

                       Set V = $ ; ( Set- assigns the variable(V) the text(String) to the right of the equal sign)

                       Let vStart = num(makedate(2011)); (Let- evaluates the expression)

                 2.

                       Set MUL = ’$1*$2’;

                       Set X = $(MUL(3,7));   // returns '3*7' in X

                       Let X = $(MUL(3,7));   // returns 21 in X

Regards

Apurva

its_anandrjs

Hi,

See the example like

1.

Let T=now( );

It will give you exact time because the value of now( ) return value assign to Let T variable and it retun time value.

2.

Set P=now( );

But SET will give and return the now( )

means what ever you write for code it accept it as string

Rgds

Anand

suniljain
Master
Master

Set x=3+4;

Let y=3+4

z=$(y)+1;

$(x) will be evaluated as ' 3+4 '

$(y) will be evaluated as ' 7 '

$(z) will be evaluated as ' 8 '

kamalqlik
Partner - Specialist
Partner - Specialist

Hi

It is very simple:

using SET you are adding string value to a variable
SET Variable1='4+5';
variable value is '4+5'

using LET you are adding an expression result to a variable
LET Variable1=4+5;
variable value is 9

Not applicable
Author

Hi,

In Qlikview  there are two variable SET and LET.The difference between these two is that the SET statement assigns literal string to SET variable,where LET Statement first evaluate the string before assigning it

e.g.

Statement                                     Value of variable

Set aVariable= 2+3;                          2+3; 

Let bVariable = 2+3;                            5;

kumarravi
Contributor III
Contributor III

It is very similar as they are named:

SET will just set the value and LET will let you define the expression/Value.

Example:

SET V_set  = 1+3  // It will store the value of "1+3" in the variable V_set

LET V_let = 1+3  // It will store the value of 4 in the variable V_let

Happy Learning 🙂 !
Vijayqlik4171
Contributor III
Contributor III

Let= Dynamic(eg Let Variable = 2*2 when you use variable some where you will get answer 4)
Set=static(eg Set Variable = 2*2 when you use variable some where you will get answer 2*2)