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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
johnnyjohn
Creator II
Creator II

Using a variable created in the load script

Hello, 

I have a variable that i define in the app directly. Let's call the variable v_DimensionToggle_Field for example. 

It is created via the in-app variable panel, and set to "=SubField('$(v_DimensionToggle)', '§', 1)"

This works well, when the user selects a dimension, it correctly parses the string, and outputs the dimension to a chart, which then plots that dimension. 

I'm trying to create this variable in the load script, not having any luck. I've tried things like 

Set v_DimensionToggle_Field = =SubField('$(v_DimensionToggle)', '§', 1);

Set v_DimensionToggle_Field = =SubField($1, '§', 1); and using that with this in the chart =$(v_DimensionToggle_Field('$(v_DimensionToggle)'))

Can't seem to be able to create this variable I need directly in the load script. 

Any help appreciated !

Labels (3)
1 Solution

Accepted Solutions
Or
MVP
MVP

Ah. If this variable isn't something you're providing in script, that definitely makes life trickier for script-side variables. 

You're going to have to either make it work with the parameterized version, or escape the dollar-sign expansion. Unfortunately, I'm not entirely sure what the exact method would be and do not have time to investigate right now. If I can, I will try and investigate further later.

 

View solution in original post

7 Replies
Or
MVP
MVP

All of these are using v_DimensionToggle, but you haven't included the definition for that particular variable. 

johnnyjohn
Creator II
Creator II
Author

You can assume string looks like dimension_field§dimension_uilabel. The parsing works well with the variable that is defined in the app directly, but can't get it to work when creating the variable in the load script

Or
MVP
MVP

Based on that definition, your original attempt should work.

Set v_DimensionToggle_Field = =SubField('$(v_DimensionToggle)', '§', 1);

Front-end dimension:

=[$(v_DimensionToggle_Field)]

 

Script used to test:

Set v_DimensionToggle = 'dimension_field§dimension_uilabel';
Set v_DimensionToggle_Field = =SubField('$(v_DimensionToggle)', '§', 1);

Load '1' as dimension_field autogenerate(1);

johnnyjohn
Creator II
Creator II
Author

It's odd. See below where I seem to be getting stuck. You can see v_test_var (created in app) is correctly evaluating the expression. You can see the v_DimensionToggle_Field is passed an empty value in the SubField function. I should mention the v_DimensionToggle is a variable that changes based on user input - it is not a static value. 

Capture.PNG

 

Or
MVP
MVP

Ah. If this variable isn't something you're providing in script, that definitely makes life trickier for script-side variables. 

You're going to have to either make it work with the parameterized version, or escape the dollar-sign expansion. Unfortunately, I'm not entirely sure what the exact method would be and do not have time to investigate right now. If I can, I will try and investigate further later.

 

johnnyjohn
Creator II
Creator II
Author

Ok, if you get the chance to have a look at some point, it would get me out of a pickle ! Thanks a lot

johnnyjohn
Creator II
Creator II
Author

You had the right idea with escaping the character - managed to do it like this. Thanks for the idea

Let v_DimensionToggle_Field = '=SubField(' & chr(39) & chr(36) & '(v_DimensionToggle)' & chr(39) & ', ' & chr(39) & '§' & chr(39) & ', 1)';