Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nleitgeb
Contributor II
Contributor II

Variables - check if exists

 

Hi there,

 

 

I´ve got some scripts in one QVW and it`s necessary to reload the script parts at different times. The reason is very easy, the raw datas exits at different times, so I can`t reload everything at once.

 

At the moment I`ve solved this with variables, that`s a very easy solution. These variables were declared once and setting by button constantly. With an if clause in the script it`s possible to activate /deactivate some parts (eg. if $(vScriptVariable1)  = 1 then [reload script part1…]… else [do nothing…] end if  [and start with the next if $(vScriptVariable2)  = 1). Actually there are about 20 script parts controlled with this solution.

 

 

But I`m not absolutely happy with this solution, because it`s possible to delete these variables and I have to declare again (regularly I delete all the variables especially to check correct initialization etc.). On the other hand I don`t like to declare these variable at every reload, because I`d like to know which script parts already done (shown by $( vScriptVariable1) ) = 1).

 

 

So, is there a way to check if a variable exists? (To be clear: I don’t need the value of the variable rather if the variable is declared!)

 

 

I´ve tried this with isnull($(vScriptVariable1)) nd with exists(($(vScriptVariable1)) but it doesn’t work.

 

 

The variable vTest in the example is just declared in order to show which case (Then or Else) is valid. Of course I´ve tried with a deleted vScriptVariable1 and a declared  vScriptVariable1.

Any ideas?

Many thanks,

 

Nicole

 

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Nicole,

Try this,

If Len(Trim('$(vScriptVariable1)')) = 0 then

Set vTest = 'Then';

Else

Set vTest = 'Else';

End If

View solution in original post

3 Replies
tamilarasu
Champion
Champion

Hi Nicole,

Try this,

If Len(Trim('$(vScriptVariable1)')) = 0 then

Set vTest = 'Then';

Else

Set vTest = 'Else';

End If

sunny_talwar

Can you try this:

If IsNull('$(vScriptVariable1)') then

or

If Len(Trim('$(vScriptVariable1)')) = 0 then

nleitgeb
Contributor II
Contributor II
Author

Hi Tamil, hi Sunny,

many thanks!! This works perfect!

Of course I also tried the isnull('$()') solution but unfortunately it doesn`t work;  function len(trim('$()') works perfect, Thank you for this perfect solution, it helps soo much,

BG,

Nicole