Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
spanda55
New Contributor III

Issue with "If" statement

Hi I am trying to evaluate this "If" statement, but it doesn't work as expected:

If(Priority= 'Critical',if(Mins>60,1,0),'NC') as MissFlg

Below is the data and the output:

Priority            Mins      MissFlg

Critical               3            0

Critical               40          0

Critical               70          0

High                  50         NC

For the 3rd row the MissFlg should evaluate to 1, as no of Mins is greater than 60, but it doesn't work.The outer If appears to work though(per the resilut in 4th row).

Could you please help?

Note: The MIns is a filed calculated from an earlier calculation which holds minutes difference between 2 timestamps.

1 Solution

Accepted Solutions
spanda55
New Contributor III

Re: Issue with "If" statement

Thanks all for your time!!

I used the Num# and it works!

If(Priority= 'Critical',if(Num#(Mins)>60,1,0),'NC') as MissFlg

View solution in original post

6 Replies
ecolomer
Honored Contributor II

Re: Issue with "If" statement

Try with:

If(Priority= 'Critical',if(Num(Mins)>60,1,0),'NC') as MissFlg

spanda55
New Contributor III

Re: Issue with "If" statement

Thanks Enrique for the quick turn.

I tried the Num function, but it didnt work.

spanda55
New Contributor III

Re: Issue with "If" statement

I changed the condition as:

If(Priority= 'Critical',if(Mins>0,1,0),'NC') as MissFlg


and it did work for Mins which are greater than 0, but when I change it to non-zero, it appears it doesn't work.

spanda55
New Contributor III

Re: Issue with "If" statement

I had just copied the part of code for better understanding, now I am copying the entire code incase if it helps:

if(Project='ABC',

If(Priority= 'Critical',if(Mins>60, 1,0),if(Priority='High', if(Mins>300,1,0),if(Priority='Medium', if(Mins>2880,1,0),if(Priority='Low', if(Mins>4320,1,0),'Not Priortized')))),

if(Project='XYZ',

If(Priority= 'Critical',if(Mins>60, 1,0),if(Priority='High', if(Mins>300,1,0),if(Priority='Medium', if(Mins>2880,1,0),if(Priority='Low', if(Mins>4320,1,0),'Not Priortized')))),'NA')) as MissFlg

nagaiank
Valued Contributor III

Re: Issue with "If" statement

The script given below generates the output shown below:

Capture.PNG

LOAD *,If(Priority='Critical',If(Mins>60,1,0),'NC') as MissFlag;

load * Inline [

Priority,Mins

Critical,3

Critical,40

Critical,70

High,50

];

spanda55
New Contributor III

Re: Issue with "If" statement

Thanks all for your time!!

I used the Num# and it works!

If(Priority= 'Critical',if(Num#(Mins)>60,1,0),'NC') as MissFlg

View solution in original post