Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Variables - define in script without error?


Hi,

I have come to the point of trying to define all variables that I need in the script, none on the GUI. That way I can avoid deleting them by mistake in the course of a cleanup - I try to delete variables either at the beginning or at the end of my script and sometimes, I just look through the variable_manager and delete them manually just to be sure that when I see a particular one, it has just been recreated in the script.

Now I have two variables in my current app that contain a GETFIELDSELECTIONS() function - so when I define them in the script, I get an error_message of course.

I cán of course define them on the GUI and just comment out the commands to define them in the script so as to have it as a backup, just in case, but I wonder:

´

=> Is it possible to define these variables in the script without triggering an error? I will post them here:

= 'BS_' &

GetFieldSelections(Monat_Jahr_Staplerkosten)

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
Not applicable

Hi Data,

you need to use SET rather than LET for variables like that


SET v = 'BS_' &GetFieldSelections(Monat_Jahr_Staplerkosten) ;

will work fine

Or if globally evaluated

SET v = ='BS_' &GetFieldSelections(Monat_Jahr_Staplerkosten) ;

hope that helps

Joe

View solution in original post

6 Replies
marcus_sommer

Hi DataNibbler,

try something like this:

set var = "= 'BS_' & GetFieldSelections(Monat_Jahr_Staplerkosten)";


- Marcus

Not applicable

Hi Data,

you need to use SET rather than LET for variables like that


SET v = 'BS_' &GetFieldSelections(Monat_Jahr_Staplerkosten) ;

will work fine

Or if globally evaluated

SET v = ='BS_' &GetFieldSelections(Monat_Jahr_Staplerkosten) ;

hope that helps

Joe

datanibbler
Champion
Champion
Author

So you can actually combine double_quotes and single quotes?

I didn't think you could.

I'll try.

datanibbler
Champion
Champion
Author

Hi Joe,

your suggestion works - almost. I need another '=' so the variable will get evaluated on the GUI and not just treated as text ...

marcus_sommer

If you used a set-statement you could combine these because there isn't any evaluation - it would be taken as it is and therefore the leading "=" inside the statement to reach a evaluation inside the gui.

- Marcus

Not applicable

Yea the second option does that for you, one thing I would add is, even with the SET statement $ is still expanded. So if you have more complex variables you need defined like this that need a $ in them, you'll need to use the right chr in a let statement, or do some build and replace on variables potentially.