Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

help with variable in script

Hi all,

I have the following variable

NUM(SUM({<sam_type={ALLOCATION}, sam_fiscal_year = {'$(=CurrentFiscalYear)'} >} sam_volume),  '#,##0.00')

This works if i create it in the Variable Overview, but if i try and create it in the script instaed i get an internal error when i look at it in the variable overview after a reload.

i am trying this

SET vAllocation_FullYear = NUM(SUM({<sam_type={ALLOCATION}, sam_fiscal_year = {'$(=CurrentFiscalYear)'} >} sam_volume),  '#,##0.00')

Does anyone know what i am doing wrong please?

Labels (1)
2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

The problem is that Qlikview will dollar-expand $(=CurrentFiscalYear) and try to evaluate it. That returns an error which then ends up in the variable.

Try:

SET vAllocation_FullYear = NUM(SUM({<sam_type={'ALLOCATION'}, sam_fiscal_year = {'^(=CurrentFiscalYear)'} >} sam_volume),  '#,##0.00');

LET vAllocation_FullYear = replace('$(vAllocation_FullYear)','^','$');

edit: works for me. see attached qvw


talk is cheap, supply exceeds demand
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Gysbert,

That doesnt work unfortunately, If i look at the variable in the variable overview window i see the following..

NUM(SUM({<sam_type={' 'ALLOCATION' '}, sam_fiscal_year = {' '$(=CurrentFiscalYear)' '} >} sam_volume),  ' '#,##0.00' ')

Note: i have put spaces above so you can see they are 2 single quotes throught the expression.