Qlik Community

Qlik Sense App Development

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

Highlighted
LP27
New Contributor III

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
Honored Contributor II

Re: Is Null condition in IF condition statement

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
];

3 Replies
trdandamudi
Honored Contributor II

Re: Is Null condition in IF condition statement

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
New Contributor III

Re: Is Null condition in IF condition statement

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

Re: Is Null condition in IF condition statement

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
];