Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Logistix
Contributor II
Contributor II

What's the difference between use or omit the let statement for defining variables

I'd like to know if there is some difference between using the Let statement for defining variables or simply omit it. On the official QlikHelp website there is an example like this: 

Example                   Result

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 '

 

In addition to these examples, I've been doing tests by myselft and the both one seems to work exactly the same. The only difference I found out between defining or not a variable was  that if you don't, It may be terminated either with a semicolon or end-of-line. 

The Qlik Offcial Documentation also says that when you omit the word let, the statement then becomes a control statement. What I don't understand. 

Is one option different to the another? And if they aren't, What's the best option to use?

Excuse the questions but I'm pretty new on Qlik Sense. 

 

Labels (2)
4 Replies
rubenmarin

Hi, I have done some test and I don't see any difference using 'LET' or omiiting it. Anyway I will keep using LET to assign a calculated value in case future versions require the keyword.

I don't see how can affect than the synax is considered a control statement. Anyway I haven't found that in documentation (with a quick search), can you link where it says that?.

What I have found is that control statements may assign variable values, in example a for..next bucle assigns a differnt value to the same variable in each iteration.

CAn you link the offical documentt

Logistix
Contributor II
Contributor II
Author

Hi,

First of all thanks a lot for your reply and trying to help me. I drop the link below where you can find exactly this piece of text:

The word let may be omitted, but the statement then becomes a control statement. Such a statement without the keyword let must be contained within a single script row and may be terminated either with a semicolon or end-of-line.

https://help.qlik.com/en-US/sense/June2020/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularS...

marcus_sommer

I suggest to use always the regular statements because like Rubin mentioned they may one day not be optional anymore.

Unfortunately the Qlik help isn't very detailed in regard to omit the LET statement but the mention of being now a control-statement should be taken as a serious hint that's not the same to apply or to omit it. There is at least one general difference between them which I know and that's the validity. Normal defined LET/SET variables are always global while control-statements itself and there created variables or further nested control-statements have an own reduced validity.

Maybe there are here and there further hints within the Qlik help by the various control-statements to their special properties whereby I doubt that they would be very detailed in this case, too.

- Marcus

Brett_Bleess
Former Employee
Former Employee

@Logistix  So, on the Help page, what you can do is use the 'Did this information...' dialog at the bottom of the section in question to leave the Doc Team a note on what you feel is confusing etc., they are very good about looking at the comments that are submitted and trying to improve things, so I think this is our best avenue on this one to be sure things get updated to reflect better guidance.  Let me know if you have questions, but hopefully it makes sense, may take a number of weeks, but they should update based upon what you provide in the way of feedback on things.

Cheers,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.