
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set Variable values based on an if then else statement
Hi everyone,
I'm trying to use the name of an app to determine where my data should be loaded from. The idea is that if an app has a ' Dev' at the end of it, i.e. 'Dashboard Dev', then data should be loaded from the development environment, else it should load from the production environment.
The 'Dashboard Dev' app will be published to a Shared Space, whereas the 'Dashboard' app will be published to the Managed Space.
So basically I'd like to use the Shared Space as the development environment and the Managed Space as the production environment.
My idea was to have a small script section in the beginning of the load script that reads something like this:
LET vDocumentTitle = DocumentTitle();
IF '$(vDocumentTitle)' = 'Dashboard Dev'
THEN
SET vLibConnection = 'Shared Space Name:Dashboard_Azure_Dev';
SET vDatabaseName = 'Database_Dev';
ELSE
SET vLibConnection = 'Shared Space Name:Dashboard_Azure_Prod';
SET vDatabaseName = 'Database_Prod';
END IF
This would then let me use variables in the following load script:
LIB CONNECT TO "$(vLibConnection)";
[Dim_Customer]:
LOAD *;
SELECT *
FROM "$(vDatabaseName)".qlik."Dim_Customer";
The latter works fine. It's the first IF...THEN...ELSE statement that fails.
It fails around the THEN statement. Any ideas as to what I'm doing wrong?
Thank you very much in advance.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bring the 'THEN' in the same line as of 'IF' - it should work fine then.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bring the 'THEN' in the same line as of 'IF' - it should work fine then.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect, thank you! That did the trick!
I was going out of my mind 😂
