Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

set an expression as a variable in the load script

Hello all, I have a QV application with a lot of expressions. Now I want to use variables to store this expressions in, so i can reuse them. You can do this in the variable overview and in the script editor. The first option works fine but in the last one i run in to a problem. For Example, I have the next formula;

Avg ({<Fact= {'X'},[Fiscal period]={$(=[PIT period])},[Fiscal year]={$(=[PIT year])}>}(Data)))/100

when I put this one in the script;

Set vExpr4Actual =           (Avg ({<Fact= {'X'},[Fiscal period]={$(=[PIT period])},[Fiscal year]={$(=[PIT year])}>}(Data)))/100;

When I run it, the formule doesn't work anymore and looks like this in the variable overview

(Avg ({<Fact= {'X'},[Fiscal period]={(internal error)},[Fiscal year]={(internal error)}>}(Data)))/100

It seems that the script engine wants to interpret the variables, can anyone help me out here?

Thanks in advance!

1 Solution

Accepted Solutions
pat_agen
Specialist
Specialist

Hi,

one workaorund which I found on this site and worked for me was to replace the "$" with it's ASCII equivalent.

so try something like this:

let vExpr4Actual='(Avg ({<Fact= {'X'},[Fiscal period]={' & chr(36) & '

(=[PIT period])},[Fiscal year]={' & chr(36) & '(=[PIT year])}>}(Data)))/100';

[Rob Wunderlich has a post on his blog putting the question of escape characters high on his wishlist for new things from qlikview to avoid this kind of messy construction]

hope this helps

View solution in original post

4 Replies
pat_agen
Specialist
Specialist

Hi,

one workaorund which I found on this site and worked for me was to replace the "$" with it's ASCII equivalent.

so try something like this:

let vExpr4Actual='(Avg ({<Fact= {'X'},[Fiscal period]={' & chr(36) & '

(=[PIT period])},[Fiscal year]={' & chr(36) & '(=[PIT year])}>}(Data)))/100';

[Rob Wunderlich has a post on his blog putting the question of escape characters high on his wishlist for new things from qlikview to avoid this kind of messy construction]

hope this helps

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Use "Let" keyword instead of "Set".

    I hope this will solve your problem

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Let wil try to evaluate the expresion, so that isn't a solution

Not applicable
Author

This answer seems to solve the problem, only i have to rewrite all the formula's.