Qlik Community

Ask a Question

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
LP27
Creator II
Creator II

Is Null condition in IF condition statement

Hi Everyone,

I have got below scenario - 

Status codePR_1PR_2Final
P108/08/1909/07/190
P204/08/18 -
P2 07/0618-
P306/03/1912/01/190

 

So I need If condition as -

If Status code ='P2' and PR_1 is blank or PR_2 is blank , then i need to place dash('-') in the Final Column or need to Place 0. ( As shown in the above table)

Currently i have written the below code and its not working :-

if(([Status code] = 'P2') and  ([PR_1] = '  ' ) or ([PR_2]= ' '),[Final] = ' -',0)

 

Could some one guide me with the best method, Maybe using Is null in If Condition 

 

 

Thanks in advance,

LP27

 

 

1 Solution

Accepted Solutions
trdandamudi
Master II
Master II

It is working on my side. Please see the attached file:

Null Condition.PNG

You can also use the below code and you will get the same result:

Data:
Load *,
if([Status code] = 'P2' and  (Len([PR_1]) = 0 ) or (Len([PR_2])= 0),'-',0) as Final;

Load * Inline [
Status code, PR_1, PR_2
P1, 08/08/19, 09/07/19
P2, 04/08/18,
P2,,07/0618
P3, 06/03/19, 12/01/19
];

View solution in original post

3 Replies
trdandamudi
Master II
Master II

Please give a try with the below code:

 

Data:
Load *,
if([Status code] = 'P2' and  ([PR_1] = '' ) or ([PR_2]= ''),'-',0) as Final;

Load * Inline [
Status code, PR_1, PR_2
P1, 08/08/19, 09/07/19
P2, 04/08/18,
P2, ,07/0618
P3, 06/03/19, 12/01/19
];

LP27
Creator II
Creator II
Author

I have got the same query, but still its not working.
trdandamudi
Master II
Master II

It is working on my side. Please see the attached file:

Null Condition.PNG

You can also use the below code and you will get the same result:

Data:
Load *,
if([Status code] = 'P2' and  (Len([PR_1]) = 0 ) or (Len([PR_2])= 0),'-',0) as Final;

Load * Inline [
Status code, PR_1, PR_2
P1, 08/08/19, 09/07/19
P2, 04/08/18,
P2,,07/0618
P3, 06/03/19, 12/01/19
];

View solution in original post