Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
madsgrathe
Partner - Creator
Partner - Creator

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.

2021-06-29_10h06_58.png

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Bring the 'THEN' in the same line as of 'IF' - it should work fine then.

tresesco_0-1624956584513.png

 

View solution in original post

2 Replies
tresesco
MVP
MVP

Bring the 'THEN' in the same line as of 'IF' - it should work fine then.

tresesco_0-1624956584513.png

 

madsgrathe
Partner - Creator
Partner - Creator
Author

Perfect, thank you! That did the trick!

I was going out of my mind 😂