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

Seript Variables issue

I have the following sameple LOAD script, where I am loading amounts in 3 currencies. I want to allow the user to select the currency being reported by selecting the ReportCurrency value in a list box (with Always One Selected Value set).

Currency:
LOAD * INLINE [
DisplayCurrency,ReportCurrency
EUR, eur
USD, usd
GBP, gbp
];

Deals:
LOAD * INLINE [
amount_gbp, amount_usd, amount_eur
100,150,110
200,300,220
];

SET Vol = '=SUM(amount_$(ReportCurrency))';



The YTDVol script variable seems to evaluate at script run time and does not recognise $(ReportCurrency). If I create a Document Variable as:

=

SUM(amount_$(=ReportCurrency))





this works OK in chart expressions, but not if I use the Vol variable set in the load script.

I've tried various syntaxes without luck yet. Can anyone help?

Thanks

Dan



6 Replies
vgutkovsky
Master II
Master II

Try this:


SET Cur = 'amount_' & $(ReportCurrency);
SET Vol = sum(Cur);


Regards,

Not applicable
Author

Hi

I'm afraid not. The $(ReportCurrency) still seems to be evaluated during script load. If I look in the Variables viewer, The Cur variable shows as 'amount_'&

vgutkovsky
Master II
Master II

Oops, my mistake, posted my reply without realizing that ReportCurrency is a field, not a variable. So of course variable expansion won't work. You can't load this in the script unless you define which value of ReportCurrency you want to use. Or do you want to cycle through all the values and have a variable hold the sum of each?

Not applicable
Author

Ideally I just want one variable for Volume. I was wondering if I could use Only(ReportCurrency) instead of variable expansion.

vgutkovsky
Master II
Master II

No, this won't work in the load script. The Only function is for expression use primarily. You would still need to define which value of ReportCurrency you want to use for the variable.

Miguel_Angel_Baeyens

Hello,

You can use something similar to

SET Vol = 'SUM(amount_' & GetFieldSelections(ReportCurrency) & ')';
in the script.