Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
fashid
Specialist
Specialist

Issue with OR statement with an AND statement

Hi Friends,

I have an issue with writing an or statement.

currently below is my if statement

     if(Sum(REQ)>0  and REQUIREMENT_NEW ='27041' or  REQUIREMENT_OLD='27041','NOT APPLICABLE','APPLICABLE') AS REQUIREMENT

But this statement is not returning the results.

i want to know if for an order i have Sum(REQ)>0 and if either of REQUIREMENT_NEW or REQUIREMENT_OLD is equal to 27041

then it it should give NOT APPLICABLE.

Now i also know why i am getting wrong results.

I am getting both NOT APPLICABLE and APPLICABLE for that particular order because i have values other than 27041 in the REQUIREMENT_OLD for that particular order.

i have attached an instance of my sample data and my sample output required

Regards,

Nadeem

Message was edited by: Nadeem Shaikh

14 Replies
Anonymous
Not applicable

You don't need to use an and, just evaluate the first condition then pass to another IF() if True;

if(Sum(REQ)>0, if(REQUIREMENT_NEW ='27041' or  REQUIREMENT_OLD='27041','NOT APPLICABLE','APPLICABLE')) AS REQUIREMENT 

vishsaggi
Champion III
Champion III

Try this?

= if(Sum(REQ)> 0  AND (REQUIREMENT_NEW ='27041' or  REQUIREMENT_OLD='27041'), 'NOT APPLICABLE', 'APPLICABLE') AS REQUIREMENT 

fashid
Specialist
Specialist
Author

Thank you for your reply gareth but this not work as i have multiple values for REQUIREMENT_OLD other than 27041

fashid
Specialist
Specialist
Author

hI vISHWARATH ,

this does not work for the same reasons

Not applicable

Try This

  if(Sum(REQ)>0  and ( REQUIREMENT_NEW ='27041' or  REQUIREMENT_OLD='27041'),'NOT APPLICABLE','APPLICABLE') AS REQUIREMENT 

Not applicable

can you pls share ur application

fashid
Specialist
Specialist
Author

hi manoj,

i have attached the excel file along with output that is required

Regards,

nadeem

Not applicable

which u have shared the source file does't have REQ column

fashid
Specialist
Specialist
Author

I have added the column