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: 
nigel987
Creator II
Creator II

what is the correct syntax for endif?

Hi, 

I'm using an if...then statement and I was wondering what the correct syntax to end it would be.

The help says it is 'end if' -> with space and semicolon

The autocomplete suggests 'endif'

So my question is: 

  • do I need to use a space between endif, or does it make a difference?
  • do I need to use a semicolon afterwards?
  • do I need to use endif AT ALL (cause it seems to work witout it)

I was just trying something simple like:

if ComputerName() = '01.....' then

SET test = 1;

Else

SET test = 2;

END IF

 

Appreciate any help. Thanks!

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

  • No it doesn't matter - you are free to use either ENDIF or END IF 
  • No you don't need a semicolon afterwards. It belongs to the group of script statements called "control statements" they have to stay on a single line and will be terminated either by a new line or a semicolon which is optional.
  • QlikView doesn't complain although it is a bit odd - the result is that all the rest of the load script belongs to the ELSE part. So it is a pretty bad idea leaving ENDIF out.

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

View solution in original post

1 Reply
petter
Partner - Champion III
Partner - Champion III

  • No it doesn't matter - you are free to use either ENDIF or END IF 
  • No you don't need a semicolon afterwards. It belongs to the group of script statements called "control statements" they have to stay on a single line and will be terminated either by a new line or a semicolon which is optional.
  • QlikView doesn't complain although it is a bit odd - the result is that all the rest of the load script belongs to the ELSE part. So it is a pretty bad idea leaving ENDIF out.

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...