Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable calculations lost in Source Control

We have implemented source control using the TFS integration.

Unfortunately, variable values are stripped out.  I guess the process treats is as "data" and therefore it is not stored.

I am a heavy user of variables to simplify set analysis expressions and reuse calculations between charts and KPI gauges, so would really like it stored in source control.

1 Solution

Accepted Solutions
ToniKautto
Employee
Employee

Variable values are considered as data and therefore not saved in the PRJ folder.

 

By declaring the variables in the load script they will be stored in the PRJ folder and thereby will not vanish.

 

It is known that in some cases variable definitions containing dollar expansions can lead to the desxribed issue. For these situations please use the workaround that was already identified above, meaning that you split the expression into two strings forcing the dollar expansion to not be expanded in the script but rather when called in application.

View solution in original post

11 Replies
Not applicable
Author

Have you tried to define variables in the script editor instead?

Not applicable
Author

That nearly works. The problem is some of the set analysis expressions.

='=Sum({$ <PremiumReceivedYearNum={$(=vMaxFinancialYearNum)} >} PremiumReceived)'

becomes

=Sum({$ <PremiumReceivedYearNum={(internal error)} >} PremiumReceived)

Not applicable
Author

A workaround could be to use

LET EXPR='=Sum({$ <PremiumReceivedYearNum={$'&'(=vMaxFinancialYearNum)} >} PremiumReceived)'

instead of

SET EXPR='=Sum({$ <PremiumReceivedYearNum={$(=vMaxFinancialYearNum)} >} PremiumReceived)'

Not applicable
Author

Thanks, that works.  It will suffice as a workaround for now.

ToniKautto
Employee
Employee

Variable values are considered as data and therefore not saved in the PRJ folder.

 

By declaring the variables in the load script they will be stored in the PRJ folder and thereby will not vanish.

 

It is known that in some cases variable definitions containing dollar expansions can lead to the desxribed issue. For these situations please use the workaround that was already identified above, meaning that you split the expression into two strings forcing the dollar expansion to not be expanded in the script but rather when called in application.

Not applicable
Author

My next issue is with variables that include single quotes in the expression.

A variable with the expression

=Date(AddMonths(Max(YearMonth), -12), 'MM-YYYY')

Needs to be written as

LET v12MonthsToMax ='=Date(AddMonths(Max(YearMonth), -12), ' & chr(39) & 'MM-YYYY' & chr(39) & ')';
kuba_michalik
Partner - Specialist
Partner - Specialist

You can avoid that using SET instead of LET (SET simply assigns everything after the equal sign to be the variable content, single quotes or no). However, you can't avoid dollar sign expansion using SET, so if you need both, you need to write a convoluted expression.

Not applicable
Author

Thanks Kuba

barryharmsen
Luminary Alumni
Luminary Alumni

Another option, that does not require unescaping/replacing, is storing the variables in an external file, load them into a temporary table and directly assign them using the peek function. You can find an example here: http://www.qlikfix.com/2011/09/21/storing-variables-outside-of-qlikview/