Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Qlikers,
I'm wondering if it il possible to use IF, THEN, ELSE in LOAD.
This is what I’m trying to do:
LOAD
if "Test" = 'empty' then
if "Test2" = 'empty' then
'Empty'
Else
'New'
End if
Else
'OLD'
End if AS "Test3"
FROM ...
Is there something wrong with my syntax, or the only possible way iln LOAD is to do
LOAD
If("Test"= 'empty', if (“Test2”=’empty’, ’empty’,’New’),’OLD’) as "Test3"
FROM ...
Thanks for your help
LOAD
If("Test"= 'empty', if (“Test2”=’empty’, ’empty’,’New’),’OLD’) as "Test3"
FROM ...
This looks right not me. Are you running into issues?
Is Test a field name? If yes, then remove the quotes. Right now it is comparing Test and empty as a string and hence the error. May be.
Hi Sunny,
Yes the following syntax is working:
If("Test"= 'empty', if (“Test2”=’empty’, ’empty’,’New’),’OLD’) as "Test3"
I want to know if the other syntax can work also
Hi Vishal,
I tried but it is not working. I think that Inside a LOAD the IF, THEN, ELSE doesn't work. So I guess I will have to write every thing like:
If("Test"= 'empty', if (“Test2”=’empty’, ’empty’,’New’),’OLD’) as "Test3"
AFAIK you cannot use the other syntax. But why are you trying to use if the second one works? Any specific reasons?
LOAD
If("Test"= 'empty', if (“Test2”=’empty’, ’empty’,’New’),’OLD’) as "Test3"
FROM ...
You can always format the load script variant by having it on separate lines and indenting it:
The // comments are optional - but to make the similarity with the former syntax clearer...
LOAD
....
If ( "Test" = 'empty , //THEN
If ( "Test2" = 'empty' , //THEN
'empty'
, //ELSE
'New'
)//ENDIF
,//ELSE
'OLD'
)//ENDIF
as "Test3",
....
It was just because the syntax with IF, THEN, ELSE, is easier to understand. But we will manage it with the syntax that works
Thanks for this trick !