Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Partner - Specialist III
Partner - Specialist III

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

beck_bakytbek
Master
Master

Hi Jaidi,

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

i hope taht helps

Beck

Not applicable
Author

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

OmarBenSalem

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

Exp:

Set 3+2 => 3+2

Let 3+2 => 5

ruchirasamant
Partner - Contributor II
Partner - Contributor II

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
Specialist III
Specialist III

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