Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Anonymous
Not applicable
Author

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
Master II
Master II

Try with:

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

Anonymous
Not applicable
Author

Thanks Enrique for the quick turn.

I tried the Num function, but it didnt work.

Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

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
Specialist III
Specialist III

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

];

Anonymous
Not applicable
Author

Thanks all for your time!!

I used the Num# and it works!

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