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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Deadpool
Contributor
Contributor

Script variable dollar expansion help

Hi

I can normally figure these out but this has had me banging my head against the wall.

On the tab I have an Input Box with a variable called vOHD which contains a decimal that the user can change.

I am trying to create a dynamic title for a chart which references the vOHD value (and displays it as a percentage).  I want to store that in another variable which I want to create in the load script. 

Example: 'OHD (' & num($(vOHD),'0%') & ')' which would show OHD (20%).

The trouble I am having is stopping the vOHD doing the dollar expansion and returning the result during the load.  Normally to avoid this I would do something like this: 'OHD (' & num($' & ' (vOHD),'0%') & ')' but I can't seem to get the correct combination to get the vOHD not to calculate too soon or not to calculate at all when enclosing the chart label in $().

example of one of many failed syntax:

set x = 'OHDs (@ ' & num($'&'(vOHD),'0%') & ')';

 

Please can you help?

Labels (1)
2 Replies
Michiel_QV_Fan
Specialist
Specialist

Not sure if I understand your issue correct. Is this what you want:

Not: set SEt_x = 'OHDs (@ ' & num($'&'(vOHD),'0%') & ')';

 

But: let let_x = 'OHDs '& $(vOHD)&' %';

 

2018-11-30 15_48_44-QlikView x64 - [D__QlikView_Uitzoekertjes_Community uitzoeken.qvw_].jpg

marcus_sommer

The easiest way would just be not to define these variables within the script else within the UI variable-editor. IMO there is not much benefit to do it within the script else it costs only efforts and is error-prone.

Should it be really within the script you need to replace the $ with anything else maybe with something in this way:

set x = "num(DOLLAR(vOHD),'0%')";
let x = replace('$(x)', 'DOLLAR', '$');

Another approach would be to read these variable-definitions from a file and then looping through the records and then assigning field-values to your variables.

But like above mentioned my first suggestion is the easiest way and you should have good reasons to take the extra costs for the script-approaches.

- Marcus