Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Set and Let

what is the difference b/w set and let?

What is the use of that? And when we are using please tel me.....

6 Replies
arvind_patil
Valued Contributor II

Re: Set and Let

Hi Rajashekar,

Please find Below:

:SET :

The SET statement is used when you want a variable to hold the string or numeric value that is to the right of the Equal (=) sign.

When used, the variable is substituted by its value.

  • Variables can be used in the script for macro expansion and in various control statements.
  • This is very useful if the same string is repeated many times in the script, e.g. a path.

Set variable = string


Eg : Set Myvar=2*3 returns “ 2*3”

LET :

The let statement, in opposition to the set statement, evaluates the expression on the right side of the ' =' before it is assigned to the macro variable.

Let variable = Expression


Eg : Let MyVar =2*3 returns “6”

Hope it helps..

Thanks,

Arvind Patil

beck110979
Valued Contributor III

Re: Set and Let

Hi Jaidi,

look at this: https://www.youtube.com/watch?v=Ez-rhEsm01c

i hope taht helps

Beck

Not applicable

Re: Set and Let

Thank you so much...............

OmarBenSalem
Esteemed Contributor

Re: Set and Let

In simple words; let performs the calculation while set does not

Exp:

Set 3+2 => 3+2

Let 3+2 => 5

ruchirasamant
New Contributor II

Re: Set and Let

Hi Rajashekar,

The below explanation may help you.

Let:-

The let statement is a complement to the set statement, used for defining script variables. The let statement, in opposition to the set statement, evaluates the expression on the right side of the ' =' before it is assigned to the variable.

Syntax:-Let variablename=expression

Set:-

The set statement is used for defining script variables. These can be used for substituting strings, paths, drives, and so on.

Syntax:- Set variablename=string

rahulpawarb
Valued Contributor II

Re: Set and Let

Use SET if you want to assign a static value to a variable

e.g. SET Dept = 'Accounts';

Use LET if you want to assign a value resulting from expression (Dynamically)

e.g. LET Dept = Peek('DepartmentName',0,'MyDept');

Regards!

Rahul Pawar

Community Browser