Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

If Condition

IF(ISNULL(TYPE)=0,'NOT_LEGAL',ELSE,'LEAGL')AS CATEGERY

I have written above code in my script. But It is not working. Can some correct it for me please.

My requirement is if  TYPE is null then the  category   should be 'NOT LEGAL' else 'LEGAL'

1 Solution

Accepted Solutions
northerner
Partner - Contributor III
Partner - Contributor III

Try:

if(isNull(TYPE), 'NOT LEGAL', 'LEGAL') as CATEGORY

IsNull will return 0 (representing false) is the TYPE field contains a non-null value.  The Qlikview if statement syntax doesn't use the 'else' keyword - comma characters are used to separate the if/then/else parts of the statement.

Hope this helps!

View solution in original post

6 Replies
northerner
Partner - Contributor III
Partner - Contributor III

Try:

if(isNull(TYPE), 'NOT LEGAL', 'LEGAL') as CATEGORY

IsNull will return 0 (representing false) is the TYPE field contains a non-null value.  The Qlikview if statement syntax doesn't use the 'else' keyword - comma characters are used to separate the if/then/else parts of the statement.

Hope this helps!

Not applicable

Hi,

It should be like this:

IF(ISNULL(TYPE), 'NOT LEGAL', 'LEGAL') AS CATEGORY

upaliwije
Creator II
Creator II
Author

Thanks for your reply and the explanation

Eduard23
Contributor III
Contributor III

Hi What if i need multiple conditions like these?

This is my expression =IF(ISNULL(INVENTORY_STATUS=1), '', 'UNRESTRICTED') its working how can i add other expected result

Inventory Status Expected Result
1 UNRESTRICTED
6EXP BLOCKED
6DMG BLOCKED
6QRN QUARANTINE
BrunPierre
Master
Master

@Eduard23 as below

If(INVENTORY_STATUS=1,'UNRESTRICTED',

If(INVENTORY_STATUS='6EXP','BLOCKED',

If(INVENTORY_STATUS='6DMG','BLOCKED',

If(INVENTORY_STATUS='6QRN','QUARANTINE',Null()))))

Eduard23
Contributor III
Contributor III

i try this one it is working but then one from BrunPierre is also working,  thanks

IF(INVENTORY_STATUS=1, 'UNRESTRICTED',IF(INVENTORY_STATUS='6DMG', 'BLOCKED',IF(INVENTORY_STATUS='6EXP', 'BLOCKED',IF(INVENTORY_STATUS='6QRN', 'QURANTINE', ''))))