Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Variable in Scripts

I  have created a variable in back end like

Let _Var = '=GetFieldSelections(Num_Month)';

Now i want to use it in my Load statement for example like below:

Load

ID,

Num_Month,

if($(_Var) = Num_Month,'Match','Not Match') as _Status

From Excel........

But i  am not getting the desired result .....????

Is it possble to use it like this ..........???

please help

6 Replies
sbobbyraj
Contributor III

Re: Variable in Scripts

Hi manish05,

To use a variable, you have tu put it into $(), in your exemple:

Load

ID,

Num_Month,

if( $(_Var) = Num_Month,'Match','Not Match') as _Status

but as you have initialized your variable before the load, I suppose you the condition you want is:

if( Num_Month= $(_Var),'Match','Not Match') as _Status

Not applicable

Re: Variable in Scripts

Still Not working

MVP
MVP

Re: Variable in Scripts

Hi

Using a Let statement produces a string. So the variable expands to the string. Change that to a set without the quotes:

Set _Var = =GetFieldSelections(Num_Month);

(the double = signs are not a typo!)

This will produce a variable whose value is the field selection. I that what you are expecting?

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sbobbyraj
Contributor III

Re: Variable in Scripts

What is the complete script? Does the filed Num_Month exists in your excel file?

Actually, the function GetFieldSelections() is not available to be used in the script, so if you use GetFieldSelections() to set the variable in the script it won't work.

MVP
MVP

Re: Variable in Scripts

But that will not produce useful value when used here.

If($(_Var) = Num_Month,'Match','Not Match') as _Status

What are you trying to compare with Num_Month?

Jonathan

PS and bobbyraj is right, GetFieldSelections does not work in script

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Variable in Scripts

But when i am using _Var in front end in the Text Obejct it is giving me the correct result , then why i can not use it in back end just below few lines after declaring the variable

Community Browser