Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello fellows,
I would like to write the following expression (pseudo-code):
// define boolean variable
let variable = true;
// check if boolean variable is true
if (true) then
// some code goes here
then
// other code
end if
QV's behavior seems to be totally cont-intuitive here, i.e. it doesn't properly check if (true) condition. SO far I've tried
- if ($(variable))
- if ($(variable) = True)
- if ($(variable) = true() )
- ...
Can someone explain how to work with boolean variables and conditional expressions?
very good doc with explanation of boolean
http://community.qlik.com/blogs/qlikviewdesignblog/2012/12/07/booleans
Hi
True() is a function returning true (-1):
let variable = true();
and then
If($(variable), <true expr>, <false expr>)
HTH
Jonathan
If <Condition> Then ....
for your case, you can try like:
Let variable=1;
If $(variable)=1 Then ...
OR
Set variable='true';
If $(variable)='true' Then ...
And also:
let variable = true();
If variable Then
... script code ...
Else
... script code
End If
very good doc with explanation of boolean
http://community.qlik.com/blogs/qlikviewdesignblog/2012/12/07/booleans
That's indeed a good article!
The problem behind was QV's way to treat variables in 'dual' form. Correct way to check a boolean value within a if expression would be either
if (variable = 'True') (note capital letter!)
or
if (variable <> 0)
Let vMyVariable = True();
If '$(vMyVariable)' = 'True' Then
// business logic here
End If
// likewise, use False() and 'False'